You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Fröstl, Christian <ch...@accenture.com> on 2018/01/25 20:33:52 UTC

Re: [External] Re: How to encode %m or %ex ?

Yes, you're right, this is exactly what I want.
If I use this %encode{%m}{JSON} notation, I only have the string "%encode" in my logfiles and not a the encoded message field.
Do you have an idea why this happens?


On 25.01.18, 19:52, "Matt Sicker" <bo...@gmail.com> wrote:

    Using %encode{%m}{JSON} will only encode the message so that it can be
    placed inside a JSON string with escapes already added. This is useful for
    creating custom JSON structures as your output. If you just want structured
    log output in general, the JSON layout (requires Jackson) is your best bet.

    On 25 January 2018 at 04:07, Fröstl, Christian <
    christian.froestl@accenture.com> wrote:

    > Hi everybody,
    >
    > I like to encode the message and the exception field to JSON notation.
    > From the docs https://urldefense.proofpoint.com/v2/url?u=https-3A__logging.apache.org_log4j_2.x_manual_layouts.html&d=DwIFaQ&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=37nF0SnGtdjmcblOpYG7cKwaPDc1GWo5GNDvnDLF8TE&m=Ev44coMgjgoj5j99VzOSlBWHAwewFMO5RTrlo7x1DjE&s=pY5vUixibqJVgDxm8ZqKxZFXJLXphXdmiSlku8MslcQ&e= I
    > have the following notation:
    > %encode{%m}{JSON}
    >
    > But this doesn't work. The only encoding which works success is the
    > default HTML encoding, if I specify the following:
    > %encode{%m}
    >
    > This is my complete code snippet:
    >             <PatternLayout>
    >                 <alwaysWriteExceptions>false</alwaysWriteExceptions>
    >                 <pattern>%level;%d{yyyy-MM-dd HH:mm:ss.SSS};%t;%c;%encode{%
    > m}{JSON}%n</pattern>
    >             </PatternLayout>
    >
    > Any hints how to use the %encode method to get JSON or CRLF encoding?
    >
    > Kind regards,
    > Christian
    >
    > On 24.01.18, 14:41, "Tungathurthi, Chandra Kiran Bharadwaj" <
    > chandra.tungathurthi@rwth-aachen.de> wrote:
    >
    >     It's log4j.configurationFile use this property to specify external
    > config.
    >
    >     As in,
    >
    >
    >
    >     `log4j.configurationFile=/path/to/log4j2.xml`
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >     On Wed, Jan 24, 2018 at 6:47 PM +0530, "Ralph Goers" <
    > ralph.goers@dslextreme.com<ma...@dslextreme.com>> wrote:
    >
    >
    >
    >
    >
    >     I’d have to look at the code to be sure, but you might try configuring
    > it as a url - file:///mypath .
    >
    >
    >
    >     Ralph
    >
    >
    >
    >     > On Jan 24, 2018, at 5:46 AM, Fröstl, Christian  wrote:
    >
    >     >
    >
    >     > Hello everybody,
    >
    >     >
    >
    >     > We like to use a log4j2.xml file for log4j2 configuration of our
    > hybris application.
    >
    >     > If the file log4j2.xml is part of the classpath and the property
    > "log4j2.config.xml=hybris-log4j2.xml" is part of my local.properties
    > file, it will be loaded automatically and everything is fine.
    >
    >     > But how can we load the file if it is located in a directory outside
    > the classpath?
    >
    >     >
    >
    >     > I tried the following:
    >
    >     > 1.Specify the absolute path in local.properties file
    >
    >     > -> Will just get many context loader and nullpointer exceptions in
    > logfile
    >
    >     >
    >
    >     > 2. Specify the log4j.configurationFile property in
    > log4j2.component.properties
    >
    >     > -> The file will be found by the system, but config will have no
    > effect. Fallback custom log will be used
    >
    >     >
    >
    >     > I found this documentation, that it should be possible to configure
    > the xml file with this properties, but it doesn't work.
    >
    >     > https://urldefense.proofpoint.com/v2/url?u=https-3A__
    > logging.apache.org_log4j_2.0_faq.html&d=DwIGaQ&c=eIGjsITfXP_y-
    > DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=37nF0SnGtdjmcblOpYG7cKwaPDc1GW
    > o5GNDvnDLF8TE&m=sNVaiG5zpbSx80M_ARXerzwh6lxhigOI7BMhyW9w2ZA&s=
    > ueOxTJdIkKbMIV6VTsZe28qJuTPCt_C2h6ijjrydcgM&e= -> How do I specify the
    > configuration file location?
    >
    >     >
    >
    >     > Does anyone have an idea to solve this problem?
    >
    >     >
    >
    >     > Thanks and greetings,
    >
    >     > Christian
    >
    >     >
    >
    >     >
    >
    >     > On 23.01.18, 17:44, "Greg Huber"  wrote:
    >
    >     >
    >
    >     >    Hello,
    >
    >     >
    >
    >     >    In a tomcat environment how do I get Log4jServletContextListener
    >
    >     >    contextDestroyed to be called last.  It is being called before my
    >
    >     >    contextDestroyed and I get no logging on shutdown.
    >
    >     >
    >
    >     >    Cheers Greg
    >
    >     >
    >
    >     >
    >
    >     >
    >
    >     > ________________________________
    >
    >     >
    >
    >     > This message is for the designated recipient only and may contain
    > privileged, proprietary, or otherwise private information. If you have
    > received it in error, please notify the sender immediately and delete the
    > original. Any other use of the email by you is prohibited.
    >
    >     >
    >
    >     > ------------------------------------------------------------
    > ---------
    >
    >     > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
    >
    >     > For additional commands, e-mail: log4j-user-help@logging.apache.org
    >
    >     >
    >
    >
    >
    >
    >
    >
    >
    >


    --
    Matt Sicker <bo...@gmail.com>



________________________________

This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.

***UNCHECKED*** Re: [External] How to encode %m or %ex ?

Posted by Ralph Goers <ra...@dslextreme.com>.
If it isn’t documented in the manual it doesn’t exist :-(

Ralph

> On Jan 26, 2018, at 9:33 AM, Matt Sicker <bo...@gmail.com> wrote:
> 
> The %encode{}{JSON} pattern was added in version 2.8.2. It doesn't appear
> to be documented on the layout manual page, but the feature is mentioned in
> the changelog for issue <https://issues.apache.org/jira/browse/LOG4J2-1848>.
> 
> On 26 January 2018 at 00:53, Fröstl, Christian <
> christian.froestl@accenture.com> wrote:
> 
>> We are using log4j2 2.7.
>> It's a hybris application and packaged with ant, or what do you want to
>> know?
>> 
>> On 25.01.18, 21:56, "Matt Sicker" <bo...@gmail.com> wrote:
>> 
>>    Can you verify the version of Log4j you're using along with how you're
>>    packaging your application?
>> 
>>    On 25 January 2018 at 14:33, Fröstl, Christian <
>>    christian.froestl@accenture.com> wrote:
>> 
>>> Yes, you're right, this is exactly what I want.
>>> If I use this %encode{%m}{JSON} notation, I only have the string
>> "%encode"
>>> in my logfiles and not a the encoded message field.
>>> Do you have an idea why this happens?
>>> 
>>> 
>>> On 25.01.18, 19:52, "Matt Sicker" <bo...@gmail.com> wrote:
>>> 
>>>    Using %encode{%m}{JSON} will only encode the message so that it
>> can be
>>>    placed inside a JSON string with escapes already added. This is
>> useful
>>> for
>>>    creating custom JSON structures as your output. If you just want
>>> structured
>>>    log output in general, the JSON layout (requires Jackson) is
>> your best
>>> bet.
>>> 
>>>    On 25 January 2018 at 04:07, Fröstl, Christian <
>>>    christian.froestl@accenture.com> wrote:
>>> 
>>>> Hi everybody,
>>>> 
>>>> I like to encode the message and the exception field to JSON
>>> notation.
>>>> From the docs https://urldefense.proofpoint.
>> com/v2/url?u=https-3A__
>>> logging.apache.org_log4j_2.x_manual_layouts.html&d=DwIFaQ&
>> c=eIGjsITfXP_y-
>>> DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=37nF0SnGtdjmcblOpYG7cKwaPDc1GW
>>> o5GNDvnDLF8TE&m=Ev44coMgjgoj5j99VzOSlBWHAwewFMO5RTrlo7x1DjE&s=
>>> pY5vUixibqJVgDxm8ZqKxZFXJLXphXdmiSlku8MslcQ&e= I
>>>> have the following notation:
>>>> %encode{%m}{JSON}
>>>> 
>>>> But this doesn't work. The only encoding which works success
>> is the
>>>> default HTML encoding, if I specify the following:
>>>> %encode{%m}
>>>> 
>>>> This is my complete code snippet:
>>>>            <PatternLayout>
>>>>                <alwaysWriteExceptions>false</
>> alwaysWriteExceptions>
>>>>                <pattern>%level;%d{yyyy-MM-dd
>>> HH:mm:ss.SSS};%t;%c;%encode{%
>>>> m}{JSON}%n</pattern>
>>>>            </PatternLayout>
>>>> 
>>>> Any hints how to use the %encode method to get JSON or CRLF
>> encoding?
>>>> 
>>>> Kind regards,
>>>> Christian
>>>> 
>>>> On 24.01.18, 14:41, "Tungathurthi, Chandra Kiran Bharadwaj" <
>>>> chandra.tungathurthi@rwth-aachen.de> wrote:
>>>> 
>>>>    It's log4j.configurationFile use this property to specify
>>> external
>>>> config.
>>>> 
>>>>    As in,
>>>> 
>>>> 
>>>> 
>>>>    `log4j.configurationFile=/path/to/log4j2.xml`
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>>    On Wed, Jan 24, 2018 at 6:47 PM +0530, "Ralph Goers" <
>>>> ralph.goers@dslextreme.com<ma...@dslextreme.com>>
>>> wrote:
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>>    I’d have to look at the code to be sure, but you might try
>>> configuring
>>>> it as a url - file:///mypath .
>>>> 
>>>> 
>>>> 
>>>>    Ralph
>>>> 
>>>> 
>>>> 
>>>>> On Jan 24, 2018, at 5:46 AM, Fröstl, Christian  wrote:
>>>> 
>>>>> 
>>>> 
>>>>> Hello everybody,
>>>> 
>>>>> 
>>>> 
>>>>> We like to use a log4j2.xml file for log4j2
>> configuration of
>>> our
>>>> hybris application.
>>>> 
>>>>> If the file log4j2.xml is part of the classpath and the
>>> property
>>>> "log4j2.config.xml=hybris-log4j2.xml" is part of my
>> local.properties
>>>> file, it will be loaded automatically and everything is fine.
>>>> 
>>>>> But how can we load the file if it is located in a
>> directory
>>> outside
>>>> the classpath?
>>>> 
>>>>> 
>>>> 
>>>>> I tried the following:
>>>> 
>>>>> 1.Specify the absolute path in local.properties file
>>>> 
>>>>> -> Will just get many context loader and nullpointer
>>> exceptions in
>>>> logfile
>>>> 
>>>>> 
>>>> 
>>>>> 2. Specify the log4j.configurationFile property in
>>>> log4j2.component.properties
>>>> 
>>>>> -> The file will be found by the system, but config will
>> have
>>> no
>>>> effect. Fallback custom log will be used
>>>> 
>>>>> 
>>>> 
>>>>> I found this documentation, that it should be possible to
>>> configure
>>>> the xml file with this properties, but it doesn't work.
>>>> 
>>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__
>>>> logging.apache.org_log4j_2.0_faq.html&d=DwIGaQ&c=eIGjsITfXP_y-
>>>> DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=
>> 37nF0SnGtdjmcblOpYG7cKwaPDc1GW
>>>> o5GNDvnDLF8TE&m=sNVaiG5zpbSx80M_ARXerzwh6lxhigOI7BMhyW9w2ZA&s=
>>>> ueOxTJdIkKbMIV6VTsZe28qJuTPCt_C2h6ijjrydcgM&e= -> How do I
>> specify
>>> the
>>>> configuration file location?
>>>> 
>>>>> 
>>>> 
>>>>> Does anyone have an idea to solve this problem?
>>>> 
>>>>> 
>>>> 
>>>>> Thanks and greetings,
>>>> 
>>>>> Christian
>>>> 
>>>>> 
>>>> 
>>>>> 
>>>> 
>>>>> On 23.01.18, 17:44, "Greg Huber"  wrote:
>>>> 
>>>>> 
>>>> 
>>>>>   Hello,
>>>> 
>>>>> 
>>>> 
>>>>>   In a tomcat environment how do I get
>>> Log4jServletContextListener
>>>> 
>>>>>   contextDestroyed to be called last.  It is being
>> called
>>> before my
>>>> 
>>>>>   contextDestroyed and I get no logging on shutdown.
>>>> 
>>>>> 
>>>> 
>>>>>   Cheers Greg
>>>> 
>>>>> 
>>>> 
>>>>> 
>>>> 
>>>>> 
>>>> 
>>>>> ________________________________
>>>> 
>>>>> 
>>>> 
>>>>> This message is for the designated recipient only and may
>>> contain
>>>> privileged, proprietary, or otherwise private information. If
>> you
>>> have
>>>> received it in error, please notify the sender immediately and
>>> delete the
>>>> original. Any other use of the email by you is prohibited.
>>>> 
>>>>> 
>>>> 
>>>>> ------------------------------
>> ------------------------------
>>>> ---------
>>>> 
>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@
>>> logging.apache.org
>>>> 
>>>>> For additional commands, e-mail: log4j-user-help@logging.
>>> apache.org
>>>> 
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>>> 
>>>    --
>>>    Matt Sicker <bo...@gmail.com>
>>> 
>>> 
>>> 
>>> ________________________________
>>> 
>>> This message is for the designated recipient only and may contain
>>> privileged, proprietary, or otherwise private information. If you
>> have
>>> received it in error, please notify the sender immediately and
>> delete the
>>> original. Any other use of the email by you is prohibited.
>>> 
>> 
>> 
>> 
>>    --
>>    Matt Sicker <bo...@gmail.com>
>> 
>> 
>> 
>> ________________________________
>> 
>> This message is for the designated recipient only and may contain
>> privileged, proprietary, or otherwise private information. If you have
>> received it in error, please notify the sender immediately and delete the
>> original. Any other use of the email by you is prohibited.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 
>> 
> 
> 
> -- 
> Matt Sicker <bo...@gmail.com>



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: [External] How to encode %m or %ex ?

Posted by Ralph Goers <ra...@dslextreme.com>.
It looks to me like it is.

Ralph

> On Jan 26, 2018, at 2:01 PM, Mikael Ståldal <mi...@apache.org> wrote:
> 
> It is documented here:
> https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout <https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout>
> 
> right?
> 
> 
> On 2018-01-26 17:33, Matt Sicker wrote:
>> The %encode{}{JSON} pattern was added in version 2.8.2. It doesn't appear
>> to be documented on the layout manual page, but the feature is mentioned in
>> the changelog for issue <https://issues.apache.org/jira/browse/LOG4J2-1848>.
>> On 26 January 2018 at 00:53, Fröstl, Christian <
>> christian.froestl@accenture.com> wrote:
>>> We are using log4j2 2.7.
>>> It's a hybris application and packaged with ant, or what do you want to
>>> know?
>>> 
>>> On 25.01.18, 21:56, "Matt Sicker" <bo...@gmail.com> wrote:
>>> 
>>>     Can you verify the version of Log4j you're using along with how you're
>>>     packaging your application?
>>> 
>>>     On 25 January 2018 at 14:33, Fröstl, Christian <
>>>     christian.froestl@accenture.com> wrote:
>>> 
>>>     > Yes, you're right, this is exactly what I want.
>>>     > If I use this %encode{%m}{JSON} notation, I only have the string
>>> "%encode"
>>>     > in my logfiles and not a the encoded message field.
>>>     > Do you have an idea why this happens?
>>>     >
>>>     >
>>>     > On 25.01.18, 19:52, "Matt Sicker" <bo...@gmail.com> wrote:
>>>     >
>>>     >     Using %encode{%m}{JSON} will only encode the message so that it
>>> can be
>>>     >     placed inside a JSON string with escapes already added. This is
>>> useful
>>>     > for
>>>     >     creating custom JSON structures as your output. If you just want
>>>     > structured
>>>     >     log output in general, the JSON layout (requires Jackson) is
>>> your best
>>>     > bet.
>>>     >
>>>     >     On 25 January 2018 at 04:07, Fröstl, Christian <
>>>     >     christian.froestl@accenture.com> wrote:
>>>     >
>>>     >     > Hi everybody,
>>>     >     >
>>>     >     > I like to encode the message and the exception field to JSON
>>>     > notation.
>>>     >     > From the docs https://urldefense.proofpoint.
>>> com/v2/url?u=https-3A__
>>>     > logging.apache.org_log4j_2.x_manual_layouts.html&d=DwIFaQ&
>>> c=eIGjsITfXP_y-
>>>     > DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=37nF0SnGtdjmcblOpYG7cKwaPDc1GW
>>>     > o5GNDvnDLF8TE&m=Ev44coMgjgoj5j99VzOSlBWHAwewFMO5RTrlo7x1DjE&s=
>>>     > pY5vUixibqJVgDxm8ZqKxZFXJLXphXdmiSlku8MslcQ&e= I
>>>     >     > have the following notation:
>>>     >     > %encode{%m}{JSON}
>>>     >     >
>>>     >     > But this doesn't work. The only encoding which works success
>>> is the
>>>     >     > default HTML encoding, if I specify the following:
>>>     >     > %encode{%m}
>>>     >     >
>>>     >     > This is my complete code snippet:
>>>     >     >             <PatternLayout>
>>>     >     >                 <alwaysWriteExceptions>false</
>>> alwaysWriteExceptions>
>>>     >     >                 <pattern>%level;%d{yyyy-MM-dd
>>>     > HH:mm:ss.SSS};%t;%c;%encode{%
>>>     >     > m}{JSON}%n</pattern>
>>>     >     >             </PatternLayout>
>>>     >     >
>>>     >     > Any hints how to use the %encode method to get JSON or CRLF
>>> encoding?
>>>     >     >
>>>     >     > Kind regards,
>>>     >     > Christian
>>>     >     >
>>>     >     > On 24.01.18, 14:41, "Tungathurthi, Chandra Kiran Bharadwaj" <
>>>     >     > chandra.tungathurthi@rwth-aachen.de> wrote:
>>>     >     >
>>>     >     >     It's log4j.configurationFile use this property to specify
>>>     > external
>>>     >     > config.
>>>     >     >
>>>     >     >     As in,
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >     `log4j.configurationFile=/path/to/log4j2.xml`
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >     On Wed, Jan 24, 2018 at 6:47 PM +0530, "Ralph Goers" <
>>>     >     > ralph.goers@dslextreme.com<ma...@dslextreme.com>>
>>>     > wrote:
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >     I’d have to look at the code to be sure, but you might try
>>>     > configuring
>>>     >     > it as a url - file:///mypath .
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >     Ralph
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >     > On Jan 24, 2018, at 5:46 AM, Fröstl, Christian  wrote:
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > Hello everybody,
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > We like to use a log4j2.xml file for log4j2
>>> configuration of
>>>     > our
>>>     >     > hybris application.
>>>     >     >
>>>     >     >     > If the file log4j2.xml is part of the classpath and the
>>>     > property
>>>     >     > "log4j2.config.xml=hybris-log4j2.xml" is part of my
>>> local.properties
>>>     >     > file, it will be loaded automatically and everything is fine.
>>>     >     >
>>>     >     >     > But how can we load the file if it is located in a
>>> directory
>>>     > outside
>>>     >     > the classpath?
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > I tried the following:
>>>     >     >
>>>     >     >     > 1.Specify the absolute path in local.properties file
>>>     >     >
>>>     >     >     > -> Will just get many context loader and nullpointer
>>>     > exceptions in
>>>     >     > logfile
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > 2. Specify the log4j.configurationFile property in
>>>     >     > log4j2.component.properties
>>>     >     >
>>>     >     >     > -> The file will be found by the system, but config will
>>> have
>>>     > no
>>>     >     > effect. Fallback custom log will be used
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > I found this documentation, that it should be possible to
>>>     > configure
>>>     >     > the xml file with this properties, but it doesn't work.
>>>     >     >
>>>     >     >     > https://urldefense.proofpoint.com/v2/url?u=https-3A__
>>>     >     > logging.apache.org_log4j_2.0_faq.html&d=DwIGaQ&c=eIGjsITfXP_y-
>>>     >     > DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=
>>> 37nF0SnGtdjmcblOpYG7cKwaPDc1GW
>>>     >     > o5GNDvnDLF8TE&m=sNVaiG5zpbSx80M_ARXerzwh6lxhigOI7BMhyW9w2ZA&s=
>>>     >     > ueOxTJdIkKbMIV6VTsZe28qJuTPCt_C2h6ijjrydcgM&e= -> How do I
>>> specify
>>>     > the
>>>     >     > configuration file location?
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > Does anyone have an idea to solve this problem?
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > Thanks and greetings,
>>>     >     >
>>>     >     >     > Christian
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > On 23.01.18, 17:44, "Greg Huber"  wrote:
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     >    Hello,
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     >    In a tomcat environment how do I get
>>>     > Log4jServletContextListener
>>>     >     >
>>>     >     >     >    contextDestroyed to be called last.  It is being
>>> called
>>>     > before my
>>>     >     >
>>>     >     >     >    contextDestroyed and I get no logging on shutdown.
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     >    Cheers Greg
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > ________________________________
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > This message is for the designated recipient only and may
>>>     > contain
>>>     >     > privileged, proprietary, or otherwise private information. If
>>> you
>>>     > have
>>>     >     > received it in error, please notify the sender immediately and
>>>     > delete the
>>>     >     > original. Any other use of the email by you is prohibited.
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >     > ------------------------------
>>> ------------------------------
>>>     >     > ---------
>>>     >     >
>>>     >     >     > To unsubscribe, e-mail: log4j-user-unsubscribe@
>>>     > logging.apache.org
>>>     >     >
>>>     >     >     > For additional commands, e-mail: log4j-user-help@logging.
>>>     > apache.org
>>>     >     >
>>>     >     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >     >
>>>     >
>>>     >
>>>     >     --
>>>     >     Matt Sicker <bo...@gmail.com>
>>>     >
>>>     >
>>>     >
>>>     > ________________________________
>>>     >
>>>     > This message is for the designated recipient only and may contain
>>>     > privileged, proprietary, or otherwise private information. If you
>>> have
>>>     > received it in error, please notify the sender immediately and
>>> delete the
>>>     > original. Any other use of the email by you is prohibited.
>>>     >
>>> 
>>> 
>>> 
>>>     --
>>>     Matt Sicker <bo...@gmail.com>
>>> 
>>> 
>>> 
>>> ________________________________
>>> 
>>> This message is for the designated recipient only and may contain
>>> privileged, proprietary, or otherwise private information. If you have
>>> received it in error, please notify the sender immediately and delete the
>>> original. Any other use of the email by you is prohibited.
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>> 
>>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org <ma...@logging.apache.org>
> For additional commands, e-mail: log4j-user-help@logging.apache.org <ma...@logging.apache.org>

Re: [External] Re: How to encode %m or %ex ?

Posted by Mikael Ståldal <mi...@apache.org>.
It is documented here:
https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout

right?


On 2018-01-26 17:33, Matt Sicker wrote:
> The %encode{}{JSON} pattern was added in version 2.8.2. It doesn't appear
> to be documented on the layout manual page, but the feature is mentioned in
> the changelog for issue <https://issues.apache.org/jira/browse/LOG4J2-1848>.
> 
> On 26 January 2018 at 00:53, Fröstl, Christian <
> christian.froestl@accenture.com> wrote:
> 
>> We are using log4j2 2.7.
>> It's a hybris application and packaged with ant, or what do you want to
>> know?
>>
>> On 25.01.18, 21:56, "Matt Sicker" <bo...@gmail.com> wrote:
>>
>>      Can you verify the version of Log4j you're using along with how you're
>>      packaging your application?
>>
>>      On 25 January 2018 at 14:33, Fröstl, Christian <
>>      christian.froestl@accenture.com> wrote:
>>
>>      > Yes, you're right, this is exactly what I want.
>>      > If I use this %encode{%m}{JSON} notation, I only have the string
>> "%encode"
>>      > in my logfiles and not a the encoded message field.
>>      > Do you have an idea why this happens?
>>      >
>>      >
>>      > On 25.01.18, 19:52, "Matt Sicker" <bo...@gmail.com> wrote:
>>      >
>>      >     Using %encode{%m}{JSON} will only encode the message so that it
>> can be
>>      >     placed inside a JSON string with escapes already added. This is
>> useful
>>      > for
>>      >     creating custom JSON structures as your output. If you just want
>>      > structured
>>      >     log output in general, the JSON layout (requires Jackson) is
>> your best
>>      > bet.
>>      >
>>      >     On 25 January 2018 at 04:07, Fröstl, Christian <
>>      >     christian.froestl@accenture.com> wrote:
>>      >
>>      >     > Hi everybody,
>>      >     >
>>      >     > I like to encode the message and the exception field to JSON
>>      > notation.
>>      >     > From the docs https://urldefense.proofpoint.
>> com/v2/url?u=https-3A__
>>      > logging.apache.org_log4j_2.x_manual_layouts.html&d=DwIFaQ&
>> c=eIGjsITfXP_y-
>>      > DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=37nF0SnGtdjmcblOpYG7cKwaPDc1GW
>>      > o5GNDvnDLF8TE&m=Ev44coMgjgoj5j99VzOSlBWHAwewFMO5RTrlo7x1DjE&s=
>>      > pY5vUixibqJVgDxm8ZqKxZFXJLXphXdmiSlku8MslcQ&e= I
>>      >     > have the following notation:
>>      >     > %encode{%m}{JSON}
>>      >     >
>>      >     > But this doesn't work. The only encoding which works success
>> is the
>>      >     > default HTML encoding, if I specify the following:
>>      >     > %encode{%m}
>>      >     >
>>      >     > This is my complete code snippet:
>>      >     >             <PatternLayout>
>>      >     >                 <alwaysWriteExceptions>false</
>> alwaysWriteExceptions>
>>      >     >                 <pattern>%level;%d{yyyy-MM-dd
>>      > HH:mm:ss.SSS};%t;%c;%encode{%
>>      >     > m}{JSON}%n</pattern>
>>      >     >             </PatternLayout>
>>      >     >
>>      >     > Any hints how to use the %encode method to get JSON or CRLF
>> encoding?
>>      >     >
>>      >     > Kind regards,
>>      >     > Christian
>>      >     >
>>      >     > On 24.01.18, 14:41, "Tungathurthi, Chandra Kiran Bharadwaj" <
>>      >     > chandra.tungathurthi@rwth-aachen.de> wrote:
>>      >     >
>>      >     >     It's log4j.configurationFile use this property to specify
>>      > external
>>      >     > config.
>>      >     >
>>      >     >     As in,
>>      >     >
>>      >     >
>>      >     >
>>      >     >     `log4j.configurationFile=/path/to/log4j2.xml`
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >     On Wed, Jan 24, 2018 at 6:47 PM +0530, "Ralph Goers" <
>>      >     > ralph.goers@dslextreme.com<ma...@dslextreme.com>>
>>      > wrote:
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >     I’d have to look at the code to be sure, but you might try
>>      > configuring
>>      >     > it as a url - file:///mypath .
>>      >     >
>>      >     >
>>      >     >
>>      >     >     Ralph
>>      >     >
>>      >     >
>>      >     >
>>      >     >     > On Jan 24, 2018, at 5:46 AM, Fröstl, Christian  wrote:
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > Hello everybody,
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > We like to use a log4j2.xml file for log4j2
>> configuration of
>>      > our
>>      >     > hybris application.
>>      >     >
>>      >     >     > If the file log4j2.xml is part of the classpath and the
>>      > property
>>      >     > "log4j2.config.xml=hybris-log4j2.xml" is part of my
>> local.properties
>>      >     > file, it will be loaded automatically and everything is fine.
>>      >     >
>>      >     >     > But how can we load the file if it is located in a
>> directory
>>      > outside
>>      >     > the classpath?
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > I tried the following:
>>      >     >
>>      >     >     > 1.Specify the absolute path in local.properties file
>>      >     >
>>      >     >     > -> Will just get many context loader and nullpointer
>>      > exceptions in
>>      >     > logfile
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > 2. Specify the log4j.configurationFile property in
>>      >     > log4j2.component.properties
>>      >     >
>>      >     >     > -> The file will be found by the system, but config will
>> have
>>      > no
>>      >     > effect. Fallback custom log will be used
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > I found this documentation, that it should be possible to
>>      > configure
>>      >     > the xml file with this properties, but it doesn't work.
>>      >     >
>>      >     >     > https://urldefense.proofpoint.com/v2/url?u=https-3A__
>>      >     > logging.apache.org_log4j_2.0_faq.html&d=DwIGaQ&c=eIGjsITfXP_y-
>>      >     > DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=
>> 37nF0SnGtdjmcblOpYG7cKwaPDc1GW
>>      >     > o5GNDvnDLF8TE&m=sNVaiG5zpbSx80M_ARXerzwh6lxhigOI7BMhyW9w2ZA&s=
>>      >     > ueOxTJdIkKbMIV6VTsZe28qJuTPCt_C2h6ijjrydcgM&e= -> How do I
>> specify
>>      > the
>>      >     > configuration file location?
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > Does anyone have an idea to solve this problem?
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > Thanks and greetings,
>>      >     >
>>      >     >     > Christian
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > On 23.01.18, 17:44, "Greg Huber"  wrote:
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     >    Hello,
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     >    In a tomcat environment how do I get
>>      > Log4jServletContextListener
>>      >     >
>>      >     >     >    contextDestroyed to be called last.  It is being
>> called
>>      > before my
>>      >     >
>>      >     >     >    contextDestroyed and I get no logging on shutdown.
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     >    Cheers Greg
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > ________________________________
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > This message is for the designated recipient only and may
>>      > contain
>>      >     > privileged, proprietary, or otherwise private information. If
>> you
>>      > have
>>      >     > received it in error, please notify the sender immediately and
>>      > delete the
>>      >     > original. Any other use of the email by you is prohibited.
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >     > ------------------------------
>> ------------------------------
>>      >     > ---------
>>      >     >
>>      >     >     > To unsubscribe, e-mail: log4j-user-unsubscribe@
>>      > logging.apache.org
>>      >     >
>>      >     >     > For additional commands, e-mail: log4j-user-help@logging.
>>      > apache.org
>>      >     >
>>      >     >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >     >
>>      >
>>      >
>>      >     --
>>      >     Matt Sicker <bo...@gmail.com>
>>      >
>>      >
>>      >
>>      > ________________________________
>>      >
>>      > This message is for the designated recipient only and may contain
>>      > privileged, proprietary, or otherwise private information. If you
>> have
>>      > received it in error, please notify the sender immediately and
>> delete the
>>      > original. Any other use of the email by you is prohibited.
>>      >
>>
>>
>>
>>      --
>>      Matt Sicker <bo...@gmail.com>
>>
>>
>>
>> ________________________________
>>
>> This message is for the designated recipient only and may contain
>> privileged, proprietary, or otherwise private information. If you have
>> received it in error, please notify the sender immediately and delete the
>> original. Any other use of the email by you is prohibited.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: [External] Re: How to encode %m or %ex ?

Posted by Matt Sicker <bo...@gmail.com>.
The %encode{}{JSON} pattern was added in version 2.8.2. It doesn't appear
to be documented on the layout manual page, but the feature is mentioned in
the changelog for issue <https://issues.apache.org/jira/browse/LOG4J2-1848>.

On 26 January 2018 at 00:53, Fröstl, Christian <
christian.froestl@accenture.com> wrote:

> We are using log4j2 2.7.
> It's a hybris application and packaged with ant, or what do you want to
> know?
>
> On 25.01.18, 21:56, "Matt Sicker" <bo...@gmail.com> wrote:
>
>     Can you verify the version of Log4j you're using along with how you're
>     packaging your application?
>
>     On 25 January 2018 at 14:33, Fröstl, Christian <
>     christian.froestl@accenture.com> wrote:
>
>     > Yes, you're right, this is exactly what I want.
>     > If I use this %encode{%m}{JSON} notation, I only have the string
> "%encode"
>     > in my logfiles and not a the encoded message field.
>     > Do you have an idea why this happens?
>     >
>     >
>     > On 25.01.18, 19:52, "Matt Sicker" <bo...@gmail.com> wrote:
>     >
>     >     Using %encode{%m}{JSON} will only encode the message so that it
> can be
>     >     placed inside a JSON string with escapes already added. This is
> useful
>     > for
>     >     creating custom JSON structures as your output. If you just want
>     > structured
>     >     log output in general, the JSON layout (requires Jackson) is
> your best
>     > bet.
>     >
>     >     On 25 January 2018 at 04:07, Fröstl, Christian <
>     >     christian.froestl@accenture.com> wrote:
>     >
>     >     > Hi everybody,
>     >     >
>     >     > I like to encode the message and the exception field to JSON
>     > notation.
>     >     > From the docs https://urldefense.proofpoint.
> com/v2/url?u=https-3A__
>     > logging.apache.org_log4j_2.x_manual_layouts.html&d=DwIFaQ&
> c=eIGjsITfXP_y-
>     > DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=37nF0SnGtdjmcblOpYG7cKwaPDc1GW
>     > o5GNDvnDLF8TE&m=Ev44coMgjgoj5j99VzOSlBWHAwewFMO5RTrlo7x1DjE&s=
>     > pY5vUixibqJVgDxm8ZqKxZFXJLXphXdmiSlku8MslcQ&e= I
>     >     > have the following notation:
>     >     > %encode{%m}{JSON}
>     >     >
>     >     > But this doesn't work. The only encoding which works success
> is the
>     >     > default HTML encoding, if I specify the following:
>     >     > %encode{%m}
>     >     >
>     >     > This is my complete code snippet:
>     >     >             <PatternLayout>
>     >     >                 <alwaysWriteExceptions>false</
> alwaysWriteExceptions>
>     >     >                 <pattern>%level;%d{yyyy-MM-dd
>     > HH:mm:ss.SSS};%t;%c;%encode{%
>     >     > m}{JSON}%n</pattern>
>     >     >             </PatternLayout>
>     >     >
>     >     > Any hints how to use the %encode method to get JSON or CRLF
> encoding?
>     >     >
>     >     > Kind regards,
>     >     > Christian
>     >     >
>     >     > On 24.01.18, 14:41, "Tungathurthi, Chandra Kiran Bharadwaj" <
>     >     > chandra.tungathurthi@rwth-aachen.de> wrote:
>     >     >
>     >     >     It's log4j.configurationFile use this property to specify
>     > external
>     >     > config.
>     >     >
>     >     >     As in,
>     >     >
>     >     >
>     >     >
>     >     >     `log4j.configurationFile=/path/to/log4j2.xml`
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >     On Wed, Jan 24, 2018 at 6:47 PM +0530, "Ralph Goers" <
>     >     > ralph.goers@dslextreme.com<ma...@dslextreme.com>>
>     > wrote:
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >     I’d have to look at the code to be sure, but you might try
>     > configuring
>     >     > it as a url - file:///mypath .
>     >     >
>     >     >
>     >     >
>     >     >     Ralph
>     >     >
>     >     >
>     >     >
>     >     >     > On Jan 24, 2018, at 5:46 AM, Fröstl, Christian  wrote:
>     >     >
>     >     >     >
>     >     >
>     >     >     > Hello everybody,
>     >     >
>     >     >     >
>     >     >
>     >     >     > We like to use a log4j2.xml file for log4j2
> configuration of
>     > our
>     >     > hybris application.
>     >     >
>     >     >     > If the file log4j2.xml is part of the classpath and the
>     > property
>     >     > "log4j2.config.xml=hybris-log4j2.xml" is part of my
> local.properties
>     >     > file, it will be loaded automatically and everything is fine.
>     >     >
>     >     >     > But how can we load the file if it is located in a
> directory
>     > outside
>     >     > the classpath?
>     >     >
>     >     >     >
>     >     >
>     >     >     > I tried the following:
>     >     >
>     >     >     > 1.Specify the absolute path in local.properties file
>     >     >
>     >     >     > -> Will just get many context loader and nullpointer
>     > exceptions in
>     >     > logfile
>     >     >
>     >     >     >
>     >     >
>     >     >     > 2. Specify the log4j.configurationFile property in
>     >     > log4j2.component.properties
>     >     >
>     >     >     > -> The file will be found by the system, but config will
> have
>     > no
>     >     > effect. Fallback custom log will be used
>     >     >
>     >     >     >
>     >     >
>     >     >     > I found this documentation, that it should be possible to
>     > configure
>     >     > the xml file with this properties, but it doesn't work.
>     >     >
>     >     >     > https://urldefense.proofpoint.com/v2/url?u=https-3A__
>     >     > logging.apache.org_log4j_2.0_faq.html&d=DwIGaQ&c=eIGjsITfXP_y-
>     >     > DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=
> 37nF0SnGtdjmcblOpYG7cKwaPDc1GW
>     >     > o5GNDvnDLF8TE&m=sNVaiG5zpbSx80M_ARXerzwh6lxhigOI7BMhyW9w2ZA&s=
>     >     > ueOxTJdIkKbMIV6VTsZe28qJuTPCt_C2h6ijjrydcgM&e= -> How do I
> specify
>     > the
>     >     > configuration file location?
>     >     >
>     >     >     >
>     >     >
>     >     >     > Does anyone have an idea to solve this problem?
>     >     >
>     >     >     >
>     >     >
>     >     >     > Thanks and greetings,
>     >     >
>     >     >     > Christian
>     >     >
>     >     >     >
>     >     >
>     >     >     >
>     >     >
>     >     >     > On 23.01.18, 17:44, "Greg Huber"  wrote:
>     >     >
>     >     >     >
>     >     >
>     >     >     >    Hello,
>     >     >
>     >     >     >
>     >     >
>     >     >     >    In a tomcat environment how do I get
>     > Log4jServletContextListener
>     >     >
>     >     >     >    contextDestroyed to be called last.  It is being
> called
>     > before my
>     >     >
>     >     >     >    contextDestroyed and I get no logging on shutdown.
>     >     >
>     >     >     >
>     >     >
>     >     >     >    Cheers Greg
>     >     >
>     >     >     >
>     >     >
>     >     >     >
>     >     >
>     >     >     >
>     >     >
>     >     >     > ________________________________
>     >     >
>     >     >     >
>     >     >
>     >     >     > This message is for the designated recipient only and may
>     > contain
>     >     > privileged, proprietary, or otherwise private information. If
> you
>     > have
>     >     > received it in error, please notify the sender immediately and
>     > delete the
>     >     > original. Any other use of the email by you is prohibited.
>     >     >
>     >     >     >
>     >     >
>     >     >     > ------------------------------
> ------------------------------
>     >     > ---------
>     >     >
>     >     >     > To unsubscribe, e-mail: log4j-user-unsubscribe@
>     > logging.apache.org
>     >     >
>     >     >     > For additional commands, e-mail: log4j-user-help@logging.
>     > apache.org
>     >     >
>     >     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >     >
>     >
>     >
>     >     --
>     >     Matt Sicker <bo...@gmail.com>
>     >
>     >
>     >
>     > ________________________________
>     >
>     > This message is for the designated recipient only and may contain
>     > privileged, proprietary, or otherwise private information. If you
> have
>     > received it in error, please notify the sender immediately and
> delete the
>     > original. Any other use of the email by you is prohibited.
>     >
>
>
>
>     --
>     Matt Sicker <bo...@gmail.com>
>
>
>
> ________________________________
>
> This message is for the designated recipient only and may contain
> privileged, proprietary, or otherwise private information. If you have
> received it in error, please notify the sender immediately and delete the
> original. Any other use of the email by you is prohibited.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
Matt Sicker <bo...@gmail.com>

Re: [External] Re: How to encode %m or %ex ?

Posted by Fröstl, Christian <ch...@accenture.com>.
We are using log4j2 2.7.
It's a hybris application and packaged with ant, or what do you want to know?

On 25.01.18, 21:56, "Matt Sicker" <bo...@gmail.com> wrote:

    Can you verify the version of Log4j you're using along with how you're
    packaging your application?

    On 25 January 2018 at 14:33, Fröstl, Christian <
    christian.froestl@accenture.com> wrote:

    > Yes, you're right, this is exactly what I want.
    > If I use this %encode{%m}{JSON} notation, I only have the string "%encode"
    > in my logfiles and not a the encoded message field.
    > Do you have an idea why this happens?
    >
    >
    > On 25.01.18, 19:52, "Matt Sicker" <bo...@gmail.com> wrote:
    >
    >     Using %encode{%m}{JSON} will only encode the message so that it can be
    >     placed inside a JSON string with escapes already added. This is useful
    > for
    >     creating custom JSON structures as your output. If you just want
    > structured
    >     log output in general, the JSON layout (requires Jackson) is your best
    > bet.
    >
    >     On 25 January 2018 at 04:07, Fröstl, Christian <
    >     christian.froestl@accenture.com> wrote:
    >
    >     > Hi everybody,
    >     >
    >     > I like to encode the message and the exception field to JSON
    > notation.
    >     > From the docs https://urldefense.proofpoint.com/v2/url?u=https-3A__
    > logging.apache.org_log4j_2.x_manual_layouts.html&d=DwIFaQ&c=eIGjsITfXP_y-
    > DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=37nF0SnGtdjmcblOpYG7cKwaPDc1GW
    > o5GNDvnDLF8TE&m=Ev44coMgjgoj5j99VzOSlBWHAwewFMO5RTrlo7x1DjE&s=
    > pY5vUixibqJVgDxm8ZqKxZFXJLXphXdmiSlku8MslcQ&e= I
    >     > have the following notation:
    >     > %encode{%m}{JSON}
    >     >
    >     > But this doesn't work. The only encoding which works success is the
    >     > default HTML encoding, if I specify the following:
    >     > %encode{%m}
    >     >
    >     > This is my complete code snippet:
    >     >             <PatternLayout>
    >     >                 <alwaysWriteExceptions>false</alwaysWriteExceptions>
    >     >                 <pattern>%level;%d{yyyy-MM-dd
    > HH:mm:ss.SSS};%t;%c;%encode{%
    >     > m}{JSON}%n</pattern>
    >     >             </PatternLayout>
    >     >
    >     > Any hints how to use the %encode method to get JSON or CRLF encoding?
    >     >
    >     > Kind regards,
    >     > Christian
    >     >
    >     > On 24.01.18, 14:41, "Tungathurthi, Chandra Kiran Bharadwaj" <
    >     > chandra.tungathurthi@rwth-aachen.de> wrote:
    >     >
    >     >     It's log4j.configurationFile use this property to specify
    > external
    >     > config.
    >     >
    >     >     As in,
    >     >
    >     >
    >     >
    >     >     `log4j.configurationFile=/path/to/log4j2.xml`
    >     >
    >     >
    >     >
    >     >
    >     >
    >     >
    >     >
    >     >
    >     >
    >     >     On Wed, Jan 24, 2018 at 6:47 PM +0530, "Ralph Goers" <
    >     > ralph.goers@dslextreme.com<ma...@dslextreme.com>>
    > wrote:
    >     >
    >     >
    >     >
    >     >
    >     >
    >     >     I’d have to look at the code to be sure, but you might try
    > configuring
    >     > it as a url - file:///mypath .
    >     >
    >     >
    >     >
    >     >     Ralph
    >     >
    >     >
    >     >
    >     >     > On Jan 24, 2018, at 5:46 AM, Fröstl, Christian  wrote:
    >     >
    >     >     >
    >     >
    >     >     > Hello everybody,
    >     >
    >     >     >
    >     >
    >     >     > We like to use a log4j2.xml file for log4j2 configuration of
    > our
    >     > hybris application.
    >     >
    >     >     > If the file log4j2.xml is part of the classpath and the
    > property
    >     > "log4j2.config.xml=hybris-log4j2.xml" is part of my local.properties
    >     > file, it will be loaded automatically and everything is fine.
    >     >
    >     >     > But how can we load the file if it is located in a directory
    > outside
    >     > the classpath?
    >     >
    >     >     >
    >     >
    >     >     > I tried the following:
    >     >
    >     >     > 1.Specify the absolute path in local.properties file
    >     >
    >     >     > -> Will just get many context loader and nullpointer
    > exceptions in
    >     > logfile
    >     >
    >     >     >
    >     >
    >     >     > 2. Specify the log4j.configurationFile property in
    >     > log4j2.component.properties
    >     >
    >     >     > -> The file will be found by the system, but config will have
    > no
    >     > effect. Fallback custom log will be used
    >     >
    >     >     >
    >     >
    >     >     > I found this documentation, that it should be possible to
    > configure
    >     > the xml file with this properties, but it doesn't work.
    >     >
    >     >     > https://urldefense.proofpoint.com/v2/url?u=https-3A__
    >     > logging.apache.org_log4j_2.0_faq.html&d=DwIGaQ&c=eIGjsITfXP_y-
    >     > DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=37nF0SnGtdjmcblOpYG7cKwaPDc1GW
    >     > o5GNDvnDLF8TE&m=sNVaiG5zpbSx80M_ARXerzwh6lxhigOI7BMhyW9w2ZA&s=
    >     > ueOxTJdIkKbMIV6VTsZe28qJuTPCt_C2h6ijjrydcgM&e= -> How do I specify
    > the
    >     > configuration file location?
    >     >
    >     >     >
    >     >
    >     >     > Does anyone have an idea to solve this problem?
    >     >
    >     >     >
    >     >
    >     >     > Thanks and greetings,
    >     >
    >     >     > Christian
    >     >
    >     >     >
    >     >
    >     >     >
    >     >
    >     >     > On 23.01.18, 17:44, "Greg Huber"  wrote:
    >     >
    >     >     >
    >     >
    >     >     >    Hello,
    >     >
    >     >     >
    >     >
    >     >     >    In a tomcat environment how do I get
    > Log4jServletContextListener
    >     >
    >     >     >    contextDestroyed to be called last.  It is being called
    > before my
    >     >
    >     >     >    contextDestroyed and I get no logging on shutdown.
    >     >
    >     >     >
    >     >
    >     >     >    Cheers Greg
    >     >
    >     >     >
    >     >
    >     >     >
    >     >
    >     >     >
    >     >
    >     >     > ________________________________
    >     >
    >     >     >
    >     >
    >     >     > This message is for the designated recipient only and may
    > contain
    >     > privileged, proprietary, or otherwise private information. If you
    > have
    >     > received it in error, please notify the sender immediately and
    > delete the
    >     > original. Any other use of the email by you is prohibited.
    >     >
    >     >     >
    >     >
    >     >     > ------------------------------------------------------------
    >     > ---------
    >     >
    >     >     > To unsubscribe, e-mail: log4j-user-unsubscribe@
    > logging.apache.org
    >     >
    >     >     > For additional commands, e-mail: log4j-user-help@logging.
    > apache.org
    >     >
    >     >     >
    >     >
    >     >
    >     >
    >     >
    >     >
    >     >
    >     >
    >     >
    >
    >
    >     --
    >     Matt Sicker <bo...@gmail.com>
    >
    >
    >
    > ________________________________
    >
    > This message is for the designated recipient only and may contain
    > privileged, proprietary, or otherwise private information. If you have
    > received it in error, please notify the sender immediately and delete the
    > original. Any other use of the email by you is prohibited.
    >



    --
    Matt Sicker <bo...@gmail.com>



________________________________

This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: [External] Re: How to encode %m or %ex ?

Posted by Matt Sicker <bo...@gmail.com>.
Can you verify the version of Log4j you're using along with how you're
packaging your application?

On 25 January 2018 at 14:33, Fröstl, Christian <
christian.froestl@accenture.com> wrote:

> Yes, you're right, this is exactly what I want.
> If I use this %encode{%m}{JSON} notation, I only have the string "%encode"
> in my logfiles and not a the encoded message field.
> Do you have an idea why this happens?
>
>
> On 25.01.18, 19:52, "Matt Sicker" <bo...@gmail.com> wrote:
>
>     Using %encode{%m}{JSON} will only encode the message so that it can be
>     placed inside a JSON string with escapes already added. This is useful
> for
>     creating custom JSON structures as your output. If you just want
> structured
>     log output in general, the JSON layout (requires Jackson) is your best
> bet.
>
>     On 25 January 2018 at 04:07, Fröstl, Christian <
>     christian.froestl@accenture.com> wrote:
>
>     > Hi everybody,
>     >
>     > I like to encode the message and the exception field to JSON
> notation.
>     > From the docs https://urldefense.proofpoint.com/v2/url?u=https-3A__
> logging.apache.org_log4j_2.x_manual_layouts.html&d=DwIFaQ&c=eIGjsITfXP_y-
> DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=37nF0SnGtdjmcblOpYG7cKwaPDc1GW
> o5GNDvnDLF8TE&m=Ev44coMgjgoj5j99VzOSlBWHAwewFMO5RTrlo7x1DjE&s=
> pY5vUixibqJVgDxm8ZqKxZFXJLXphXdmiSlku8MslcQ&e= I
>     > have the following notation:
>     > %encode{%m}{JSON}
>     >
>     > But this doesn't work. The only encoding which works success is the
>     > default HTML encoding, if I specify the following:
>     > %encode{%m}
>     >
>     > This is my complete code snippet:
>     >             <PatternLayout>
>     >                 <alwaysWriteExceptions>false</alwaysWriteExceptions>
>     >                 <pattern>%level;%d{yyyy-MM-dd
> HH:mm:ss.SSS};%t;%c;%encode{%
>     > m}{JSON}%n</pattern>
>     >             </PatternLayout>
>     >
>     > Any hints how to use the %encode method to get JSON or CRLF encoding?
>     >
>     > Kind regards,
>     > Christian
>     >
>     > On 24.01.18, 14:41, "Tungathurthi, Chandra Kiran Bharadwaj" <
>     > chandra.tungathurthi@rwth-aachen.de> wrote:
>     >
>     >     It's log4j.configurationFile use this property to specify
> external
>     > config.
>     >
>     >     As in,
>     >
>     >
>     >
>     >     `log4j.configurationFile=/path/to/log4j2.xml`
>     >
>     >
>     >
>     >
>     >
>     >
>     >
>     >
>     >
>     >     On Wed, Jan 24, 2018 at 6:47 PM +0530, "Ralph Goers" <
>     > ralph.goers@dslextreme.com<ma...@dslextreme.com>>
> wrote:
>     >
>     >
>     >
>     >
>     >
>     >     I’d have to look at the code to be sure, but you might try
> configuring
>     > it as a url - file:///mypath .
>     >
>     >
>     >
>     >     Ralph
>     >
>     >
>     >
>     >     > On Jan 24, 2018, at 5:46 AM, Fröstl, Christian  wrote:
>     >
>     >     >
>     >
>     >     > Hello everybody,
>     >
>     >     >
>     >
>     >     > We like to use a log4j2.xml file for log4j2 configuration of
> our
>     > hybris application.
>     >
>     >     > If the file log4j2.xml is part of the classpath and the
> property
>     > "log4j2.config.xml=hybris-log4j2.xml" is part of my local.properties
>     > file, it will be loaded automatically and everything is fine.
>     >
>     >     > But how can we load the file if it is located in a directory
> outside
>     > the classpath?
>     >
>     >     >
>     >
>     >     > I tried the following:
>     >
>     >     > 1.Specify the absolute path in local.properties file
>     >
>     >     > -> Will just get many context loader and nullpointer
> exceptions in
>     > logfile
>     >
>     >     >
>     >
>     >     > 2. Specify the log4j.configurationFile property in
>     > log4j2.component.properties
>     >
>     >     > -> The file will be found by the system, but config will have
> no
>     > effect. Fallback custom log will be used
>     >
>     >     >
>     >
>     >     > I found this documentation, that it should be possible to
> configure
>     > the xml file with this properties, but it doesn't work.
>     >
>     >     > https://urldefense.proofpoint.com/v2/url?u=https-3A__
>     > logging.apache.org_log4j_2.0_faq.html&d=DwIGaQ&c=eIGjsITfXP_y-
>     > DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=37nF0SnGtdjmcblOpYG7cKwaPDc1GW
>     > o5GNDvnDLF8TE&m=sNVaiG5zpbSx80M_ARXerzwh6lxhigOI7BMhyW9w2ZA&s=
>     > ueOxTJdIkKbMIV6VTsZe28qJuTPCt_C2h6ijjrydcgM&e= -> How do I specify
> the
>     > configuration file location?
>     >
>     >     >
>     >
>     >     > Does anyone have an idea to solve this problem?
>     >
>     >     >
>     >
>     >     > Thanks and greetings,
>     >
>     >     > Christian
>     >
>     >     >
>     >
>     >     >
>     >
>     >     > On 23.01.18, 17:44, "Greg Huber"  wrote:
>     >
>     >     >
>     >
>     >     >    Hello,
>     >
>     >     >
>     >
>     >     >    In a tomcat environment how do I get
> Log4jServletContextListener
>     >
>     >     >    contextDestroyed to be called last.  It is being called
> before my
>     >
>     >     >    contextDestroyed and I get no logging on shutdown.
>     >
>     >     >
>     >
>     >     >    Cheers Greg
>     >
>     >     >
>     >
>     >     >
>     >
>     >     >
>     >
>     >     > ________________________________
>     >
>     >     >
>     >
>     >     > This message is for the designated recipient only and may
> contain
>     > privileged, proprietary, or otherwise private information. If you
> have
>     > received it in error, please notify the sender immediately and
> delete the
>     > original. Any other use of the email by you is prohibited.
>     >
>     >     >
>     >
>     >     > ------------------------------------------------------------
>     > ---------
>     >
>     >     > To unsubscribe, e-mail: log4j-user-unsubscribe@
> logging.apache.org
>     >
>     >     > For additional commands, e-mail: log4j-user-help@logging.
> apache.org
>     >
>     >     >
>     >
>     >
>     >
>     >
>     >
>     >
>     >
>     >
>
>
>     --
>     Matt Sicker <bo...@gmail.com>
>
>
>
> ________________________________
>
> This message is for the designated recipient only and may contain
> privileged, proprietary, or otherwise private information. If you have
> received it in error, please notify the sender immediately and delete the
> original. Any other use of the email by you is prohibited.
>



-- 
Matt Sicker <bo...@gmail.com>