logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Zavizionov <alexey.zavizio...@gmail.com>
Subject Re: How to print timestamp on each log line of a stack trace?
Date Thu, 18 Dec 2014 15:04:21 GMT
Any news on it?

On Thu, Nov 6, 2014 at 3:03 PM, Alexey Zavizionov <
alexey.zavizionov@gmail.com> wrote:
>
> Btw, I found "separator" option, but \n or %n didn't work for it!
>
>             <PatternLayout>
>                 <pattern>%d{HH:mm:ss.SSS} : %m [] %xEx{separator(\n)}
> %n</pattern>
>             </PatternLayout>
>
> I want to use %d in it.
>
> Please try to fix the with it.
> org.apache.logging.log4j.core.pattern.ThrowablePatternConverter.formatOption(Throwable,
> StringBuilder)
>
>
> On Thu, Nov 6, 2014 at 10:31 AM, Alexey Zavizionov <
> alexey.zavizionov@gmail.com> wrote:
>
>> Thank! Where to put it in my conf to not broke other log configuration?
>> 05 нояб. 2014 г. 21:42 пользователь "Ralph Goers" <
>> ralph.goers@dslextreme.com> написал:
>>
>> You would have to create a custom ThrowablePatternConverter.
>>>
>>> Ralph
>>>
>>> > On Nov 5, 2014, at 12:03 PM, Alexey Zavizionov <
>>> alexey.zavizionov@gmail.com> wrote:
>>> >
>>> > Here is the output, when an application is throwing an exception,
>>> logging
>>> > it to log, including its stack trace.
>>> >
>>> > E 1105-2042:17,349 c.e.TestLog error-message [main]
>>> > java.lang.Exception: SomeError
>>> >  at com.examples.TestLog.main(TestLog.java:15)
>>> >
>>> > Want to see the timestamp "E 1105-2042:17,349" on each log line.
>>> > How can I do? Is it possible with configuration file?
>>> >
>>> > TestLog.java
>>> > =============================================
>>> > public class TestLog {
>>> > private static final Logger LOGGER =
>>> LoggerFactory.getLogger(TestLog.class);
>>> > public static void main(String[] args) {
>>> > LOGGER.error("error-", new Exception("SomeError"));
>>> > }
>>> > }
>>> > =============================================
>>> >
>>> > log4j2.xml
>>> > =============================================
>>> > <?xml version="1.0" encoding="UTF-8"?>
>>> > <Configuration status="WARN">
>>> >    <Appenders>
>>> >        <RollingRandomAccessFile name="server" fileName="server.log"
>>> > filePattern="server-%d-%i.log.zip" immediateFlush="false">
>>> >            <ThresholdFilter level="DEBUG" />
>>> >            <PatternLayout>
>>> >                <pattern>%level{length=1} %date{MMdd-HHmm:ss,SSS}
>>> > %logger{1.} %message [%thread]%n</pattern>
>>> >            </PatternLayout>
>>> >            <Policies>
>>> >                <TimeBasedTriggeringPolicy />
>>> >                <SizeBasedTriggeringPolicy size="50 MB" />
>>> >            </Policies>
>>> >            <DefaultRolloverStrategy max="100" />
>>> >        </RollingRandomAccessFile>
>>> >    </Appenders>
>>> >    <Loggers>
>>> >        <Root level="DEBUG">
>>> >            <AppenderRef ref="server" />
>>> >        </Root>
>>> >    </Loggers>
>>> > </Configuration>
>>> > =============================================
>>> >
>>> > I have log:
>>> > ==============================================
>>> > E 1105-2042:17,349 c.e.TestLog error-message [main]
>>> > java.lang.Exception: SomeError
>>> >  at com.examples.TestLog.main(TestLog.java:15)
>>> > ==============================================
>>> >
>>> > Hope to see log:
>>> > ==============================================
>>> > E 1105-2042:17,349 c.e.TestLog error-message  [main]
>>> > E 1105-2042:17,349 java.lang.Exception: SomeError
>>> > E 1105-2042:17,349  at com.examples.TestLog.main(TestLog.java:15)
>>> > ==============================================
>>> >
>>> > Regards,
>>> > Alexey.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>>
>>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message