You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Chathura Priyankara <pr...@gmail.com> on 2015/04/10 05:59:42 UTC

[Dev][log4j] Log4j 2.x LoggingEvent is not supported

Hi,

I'm trying to upgrade Log4j 1.2.17 to Log4j 2.2. First I tried to do this
using Log4j 1.x bridge as mentioned in [1], but I couldn't find a way to
use LoggingEvent with log4j 2.2.
In Log4j 2.x LoggingEvent is removed or I'm missing something ?
Is there something similar to LoggingEvent in the new version ?

[1] https://logging.apache.org/log4j/2.x/manual/migration.html

Thanks,
Best Regards,
Chathura.

-- 
Chathura Priyankara,
Faculty of Information Technology,
University of Moratuwa.
Blog  : www.codeoncloud.blogspot.com

Re: [Dev][log4j] Log4j 2.x LoggingEvent is not supported

Posted by Chathura Priyankara <pr...@gmail.com>.
Hi Ralph,

I'm in the process of upgrading log4j 1.2 custom console appender to Log4j
2. Here the LoggingEvent is used to get the log event from the
java.util.logging.LogRecord and then to doAppend that log event. Eg:
LoggingEvent loggingEvent = LoggingUtils.getLogEvent(record);
doAppend(loggingEvent);

Is there anyway that I can create a custom console appender ?
I cannot find a sample for this.

Any help is appreciated.

Thanks!

On Fri, Apr 17, 2015 at 12:13 PM, Chathura Priyankara <
priyankarahac@gmail.com> wrote:

> Hi
>
> I'm in the process of upgrading log4j 1.2 custom console appender to
> Log4j 2. Here the LoggingEvent is used to get the log event from the
> java.util.logging.LogRecord and then to doAppend that log event. Eg:
> LoggingEvent loggingEvent = LoggingUtils.getLogEvent(record);
> doAppend(loggingEvent);
>
> Is there anyway that I can create a custom console appender ?
> I cannot find a sample for this.
>
> Any help is appreciated.
>
> Thanks!
> Chathura.
>
> On Fri, Apr 10, 2015 at 9:02 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> This really doesn’t tell me what you are trying to do. Where did you get
>> the LogRecord from and why do you need the LoggingEvent?
>>
>> The class that corresponds to a LoggingEvent is the LogEvent interface
>> which is backed by the Log4jLogEvent class. As I said, these are internal
>> to Log4j 2 and really shouldn’t be used directly, so it would be really
>> helpful to know what you are trying to do so we can offer advice on how to
>> do it.
>>
>> Ralph
>>
>> On Apr 9, 2015, at 9:31 PM, Chathura Priyankara <pr...@gmail.com>
>> wrote:
>>
>> Hi Ralph.
>>
>> Thank you very much for the response.
>>
>> I want to return a logging event from the given log record. So in the
>> application that I'm trying to upgrade there is an implementation to get
>> log event like follows :
>>
>> public static LoggingEvent getLogEvent(LogRecord record) {
>>     Priority level = getLogLevel(record.getLevel());
>>
>>     return new LoggingEvent(record.getSourceClassName(),
>>             Logger.getLogger(record.getSourceClassName()), level,
>>             record.getMessage(), record.getThrown());
>> }
>>
>> So is there anyway that I can make this work ?
>>
>> Regards,
>> Chathura.
>>
>>
>>
>> On Fri, Apr 10, 2015 at 9:51 AM, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>>
>>> The equivalent of the LoggingEvent is an internal part of the Log4j 2
>>> core. Can you explain what you are trying to do?
>>>
>>> Ralph
>>>
>>> On Apr 9, 2015, at 8:59 PM, Chathura Priyankara <pr...@gmail.com>
>>> wrote:
>>>
>>> Hi,
>>>
>>> I'm trying to upgrade Log4j 1.2.17 to Log4j 2.2. First I tried to do
>>> this using Log4j 1.x bridge as mentioned in [1], but I couldn't find a way
>>> to use LoggingEvent with log4j 2.2.
>>> In Log4j 2.x LoggingEvent is removed or I'm missing something ?
>>> Is there something similar to LoggingEvent in the new version ?
>>>
>>> [1] https://logging.apache.org/log4j/2.x/manual/migration.html
>>>
>>> Thanks,
>>> Best Regards,
>>> Chathura.
>>>
>>> --
>>> Chathura Priyankara,
>>> Faculty of Information Technology,
>>> University of Moratuwa.
>>> Blog  : www.codeoncloud.blogspot.com
>>>
>>>
>>
>>
>> --
>> Chathura Priyankara,
>> Faculty of Information Technology,
>> University of Moratuwa.
>> Blog  : www.codeoncloud.blogspot.com
>>
>>
>>
>
>
> --
> Chathura Priyankara,
> Faculty of Information Technology,
> University of Moratuwa.
> Blog  : www.codeoncloud.blogspot.com
>



-- 
Chathura Priyankara,
Faculty of Information Technology,
University of Moratuwa.
Blog  : www.codeoncloud.blogspot.com

Re: [Dev][log4j] Log4j 2.x LoggingEvent is not supported

Posted by Remko Popma <re...@gmail.com>.
If you want to route java util logging to log4j2, you may not need a custom appender. Please look at the JUL adapter that is included in log4j2. 

You'll need to put the log4j-jul jar in your classpath and set a system property. Please refer to the log4j2 web site for details. 

Remko

Sent from my iPhone

> On 2015/04/17, at 15:43, Chathura Priyankara <pr...@gmail.com> wrote:
> 
> Hi
> 
> I'm in the process of upgrading log4j 1.2 custom console appender to Log4j 2. Here the LoggingEvent is used to get the log event from the  java.util.logging.LogRecord and then to doAppend that log event. Eg: LoggingEvent loggingEvent = LoggingUtils.getLogEvent(record); doAppend(loggingEvent);
> 
> Is there anyway that I can create a custom console appender ?
> I cannot find a sample for this.
> 
> Any help is appreciated. 
> 
> Thanks!
> Chathura.
> 
>> On Fri, Apr 10, 2015 at 9:02 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>> This really doesn’t tell me what you are trying to do. Where did you get the LogRecord from and why do you need the LoggingEvent?  
>> 
>> The class that corresponds to a LoggingEvent is the LogEvent interface which is backed by the Log4jLogEvent class. As I said, these are internal to Log4j 2 and really shouldn’t be used directly, so it would be really helpful to know what you are trying to do so we can offer advice on how to do it.
>> 
>> Ralph
>> 
>>> On Apr 9, 2015, at 9:31 PM, Chathura Priyankara <pr...@gmail.com> wrote:
>>> 
>>> Hi Ralph.
>>> 
>>> Thank you very much for the response.
>>> 
>>> I want to return a logging event from the given log record. So in the application that I'm trying to upgrade there is an implementation to get log event like follows :
>>> 
>>> public static LoggingEvent getLogEvent(LogRecord record) {
>>>     Priority level = getLogLevel(record.getLevel());
>>> 
>>>     return new LoggingEvent(record.getSourceClassName(),
>>>             Logger.getLogger(record.getSourceClassName()), level,
>>>             record.getMessage(), record.getThrown());
>>> }
>>> 
>>> So is there anyway that I can make this work ?
>>> Regards,
>>> Chathura.
>>> 
>>> 
>>>> On Fri, Apr 10, 2015 at 9:51 AM, Ralph Goers <ra...@dslextreme.com> wrote:
>>>> The equivalent of the LoggingEvent is an internal part of the Log4j 2 core. Can you explain what you are trying to do?
>>>> 
>>>> Ralph
>>>> 
>>>>> On Apr 9, 2015, at 8:59 PM, Chathura Priyankara <pr...@gmail.com> wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> I'm trying to upgrade Log4j 1.2.17 to Log4j 2.2. First I tried to do this using Log4j 1.x bridge as mentioned in [1], but I couldn't find a way to use LoggingEvent with log4j 2.2. 
>>>>> In Log4j 2.x LoggingEvent is removed or I'm missing something ?
>>>>> Is there something similar to LoggingEvent in the new version ?
>>>>> 
>>>>> [1] https://logging.apache.org/log4j/2.x/manual/migration.html
>>>>> 
>>>>> Thanks,
>>>>> Best Regards,
>>>>> Chathura.
>>>>> 
>>>>> -- 
>>>>> Chathura Priyankara,
>>>>> Faculty of Information Technology,
>>>>> University of Moratuwa.
>>>>> Blog  : www.codeoncloud.blogspot.com
>>> 
>>> 
>>> 
>>> -- 
>>> Chathura Priyankara,
>>> Faculty of Information Technology,
>>> University of Moratuwa.
>>> Blog  : www.codeoncloud.blogspot.com
> 
> 
> 
> -- 
> Chathura Priyankara,
> Faculty of Information Technology,
> University of Moratuwa.
> Blog  : www.codeoncloud.blogspot.com

Re: [Dev][log4j] Log4j 2.x LoggingEvent is not supported

Posted by Gary Gregory <ga...@gmail.com>.
Log4j 2 includes some JUL support. Is that what you are trying to do?

Gary

On Thu, Apr 16, 2015 at 11:43 PM, Chathura Priyankara <
priyankarahac@gmail.com> wrote:

> Hi
>
> I'm in the process of upgrading log4j 1.2 custom console appender to
> Log4j 2. Here the LoggingEvent is used to get the log event from the
> java.util.logging.LogRecord and then to doAppend that log event. Eg:
> LoggingEvent loggingEvent = LoggingUtils.getLogEvent(record);
> doAppend(loggingEvent);
>
> Is there anyway that I can create a custom console appender ?
> I cannot find a sample for this.
>
> Any help is appreciated.
>
> Thanks!
> Chathura.
>
> On Fri, Apr 10, 2015 at 9:02 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> This really doesn’t tell me what you are trying to do. Where did you get
>> the LogRecord from and why do you need the LoggingEvent?
>>
>> The class that corresponds to a LoggingEvent is the LogEvent interface
>> which is backed by the Log4jLogEvent class. As I said, these are internal
>> to Log4j 2 and really shouldn’t be used directly, so it would be really
>> helpful to know what you are trying to do so we can offer advice on how to
>> do it.
>>
>> Ralph
>>
>> On Apr 9, 2015, at 9:31 PM, Chathura Priyankara <pr...@gmail.com>
>> wrote:
>>
>> Hi Ralph.
>>
>> Thank you very much for the response.
>>
>> I want to return a logging event from the given log record. So in the
>> application that I'm trying to upgrade there is an implementation to get
>> log event like follows :
>>
>> public static LoggingEvent getLogEvent(LogRecord record) {
>>     Priority level = getLogLevel(record.getLevel());
>>
>>     return new LoggingEvent(record.getSourceClassName(),
>>             Logger.getLogger(record.getSourceClassName()), level,
>>             record.getMessage(), record.getThrown());
>> }
>>
>> So is there anyway that I can make this work ?
>>
>> Regards,
>> Chathura.
>>
>>
>>
>> On Fri, Apr 10, 2015 at 9:51 AM, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>>
>>> The equivalent of the LoggingEvent is an internal part of the Log4j 2
>>> core. Can you explain what you are trying to do?
>>>
>>> Ralph
>>>
>>> On Apr 9, 2015, at 8:59 PM, Chathura Priyankara <pr...@gmail.com>
>>> wrote:
>>>
>>> Hi,
>>>
>>> I'm trying to upgrade Log4j 1.2.17 to Log4j 2.2. First I tried to do
>>> this using Log4j 1.x bridge as mentioned in [1], but I couldn't find a way
>>> to use LoggingEvent with log4j 2.2.
>>> In Log4j 2.x LoggingEvent is removed or I'm missing something ?
>>> Is there something similar to LoggingEvent in the new version ?
>>>
>>> [1] https://logging.apache.org/log4j/2.x/manual/migration.html
>>>
>>> Thanks,
>>> Best Regards,
>>> Chathura.
>>>
>>> --
>>> Chathura Priyankara,
>>> Faculty of Information Technology,
>>> University of Moratuwa.
>>> Blog  : www.codeoncloud.blogspot.com
>>>
>>>
>>
>>
>> --
>> Chathura Priyankara,
>> Faculty of Information Technology,
>> University of Moratuwa.
>> Blog  : www.codeoncloud.blogspot.com
>>
>>
>>
>
>
> --
> Chathura Priyankara,
> Faculty of Information Technology,
> University of Moratuwa.
> Blog  : www.codeoncloud.blogspot.com
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [Dev][log4j] Log4j 2.x LoggingEvent is not supported

Posted by Chathura Priyankara <pr...@gmail.com>.
Hi

I'm in the process of upgrading log4j 1.2 custom console appender to Log4j
2. Here the LoggingEvent is used to get the log event from the
java.util.logging.LogRecord and then to doAppend that log event. Eg:
LoggingEvent loggingEvent = LoggingUtils.getLogEvent(record);
doAppend(loggingEvent);

Is there anyway that I can create a custom console appender ?
I cannot find a sample for this.

Any help is appreciated.

Thanks!
Chathura.

On Fri, Apr 10, 2015 at 9:02 PM, Ralph Goers <ra...@dslextreme.com>
wrote:

> This really doesn’t tell me what you are trying to do. Where did you get
> the LogRecord from and why do you need the LoggingEvent?
>
> The class that corresponds to a LoggingEvent is the LogEvent interface
> which is backed by the Log4jLogEvent class. As I said, these are internal
> to Log4j 2 and really shouldn’t be used directly, so it would be really
> helpful to know what you are trying to do so we can offer advice on how to
> do it.
>
> Ralph
>
> On Apr 9, 2015, at 9:31 PM, Chathura Priyankara <pr...@gmail.com>
> wrote:
>
> Hi Ralph.
>
> Thank you very much for the response.
>
> I want to return a logging event from the given log record. So in the
> application that I'm trying to upgrade there is an implementation to get
> log event like follows :
>
> public static LoggingEvent getLogEvent(LogRecord record) {
>     Priority level = getLogLevel(record.getLevel());
>
>     return new LoggingEvent(record.getSourceClassName(),
>             Logger.getLogger(record.getSourceClassName()), level,
>             record.getMessage(), record.getThrown());
> }
>
> So is there anyway that I can make this work ?
>
> Regards,
> Chathura.
>
>
>
> On Fri, Apr 10, 2015 at 9:51 AM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> The equivalent of the LoggingEvent is an internal part of the Log4j 2
>> core. Can you explain what you are trying to do?
>>
>> Ralph
>>
>> On Apr 9, 2015, at 8:59 PM, Chathura Priyankara <pr...@gmail.com>
>> wrote:
>>
>> Hi,
>>
>> I'm trying to upgrade Log4j 1.2.17 to Log4j 2.2. First I tried to do this
>> using Log4j 1.x bridge as mentioned in [1], but I couldn't find a way to
>> use LoggingEvent with log4j 2.2.
>> In Log4j 2.x LoggingEvent is removed or I'm missing something ?
>> Is there something similar to LoggingEvent in the new version ?
>>
>> [1] https://logging.apache.org/log4j/2.x/manual/migration.html
>>
>> Thanks,
>> Best Regards,
>> Chathura.
>>
>> --
>> Chathura Priyankara,
>> Faculty of Information Technology,
>> University of Moratuwa.
>> Blog  : www.codeoncloud.blogspot.com
>>
>>
>
>
> --
> Chathura Priyankara,
> Faculty of Information Technology,
> University of Moratuwa.
> Blog  : www.codeoncloud.blogspot.com
>
>
>


-- 
Chathura Priyankara,
Faculty of Information Technology,
University of Moratuwa.
Blog  : www.codeoncloud.blogspot.com

Re: [Dev][log4j] Log4j 2.x LoggingEvent is not supported

Posted by Ralph Goers <ra...@dslextreme.com>.
This really doesn’t tell me what you are trying to do. Where did you get the LogRecord from and why do you need the LoggingEvent?  

The class that corresponds to a LoggingEvent is the LogEvent interface which is backed by the Log4jLogEvent class. As I said, these are internal to Log4j 2 and really shouldn’t be used directly, so it would be really helpful to know what you are trying to do so we can offer advice on how to do it.

Ralph

> On Apr 9, 2015, at 9:31 PM, Chathura Priyankara <pr...@gmail.com> wrote:
> 
> Hi Ralph.
> 
> Thank you very much for the response.
> 
> I want to return a logging event from the given log record. So in the application that I'm trying to upgrade there is an implementation to get log event like follows :
> 
> public static LoggingEvent getLogEvent(LogRecord record) {
>     Priority level = getLogLevel(record.getLevel());
> 
>     return new LoggingEvent(record.getSourceClassName(),
>             Logger.getLogger(record.getSourceClassName()), level,
>             record.getMessage(), record.getThrown());
> }
> 
> So is there anyway that I can make this work ?
> Regards,
> Chathura.
> 
> 
> On Fri, Apr 10, 2015 at 9:51 AM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> The equivalent of the LoggingEvent is an internal part of the Log4j 2 core. Can you explain what you are trying to do?
> 
> Ralph
> 
> On Apr 9, 2015, at 8:59 PM, Chathura Priyankara <priyankarahac@gmail.com <ma...@gmail.com>> wrote:
> 
>> Hi,
>> 
>> I'm trying to upgrade Log4j 1.2.17 to Log4j 2.2. First I tried to do this using Log4j 1.x bridge as mentioned in [1], but I couldn't find a way to use LoggingEvent with log4j 2.2. 
>> In Log4j 2.x LoggingEvent is removed or I'm missing something ?
>> Is there something similar to LoggingEvent in the new version ?
>> 
>> [1] https://logging.apache.org/log4j/2.x/manual/migration.html <https://logging.apache.org/log4j/2.x/manual/migration.html>
>> 
>> Thanks,
>> Best Regards,
>> Chathura.
>> 
>> -- 
>> Chathura Priyankara,
>> Faculty of Information Technology,
>> University of Moratuwa.
>> Blog  : www.codeoncloud.blogspot.com <http://www.codeoncloud.blogspot.com/>
> 
> 
> 
> -- 
> Chathura Priyankara,
> Faculty of Information Technology,
> University of Moratuwa.
> Blog  : www.codeoncloud.blogspot.com <http://www.codeoncloud.blogspot.com/>


Re: [Dev][log4j] Log4j 2.x LoggingEvent is not supported

Posted by Chathura Priyankara <pr...@gmail.com>.
Hi Ralph.

Thank you very much for the response.

I want to return a logging event from the given log record. So in the
application that I'm trying to upgrade there is an implementation to get
log event like follows :

public static LoggingEvent getLogEvent(LogRecord record) {
    Priority level = getLogLevel(record.getLevel());

    return new LoggingEvent(record.getSourceClassName(),
            Logger.getLogger(record.getSourceClassName()), level,
            record.getMessage(), record.getThrown());
}

So is there anyway that I can make this work ?

Regards,
Chathura.



On Fri, Apr 10, 2015 at 9:51 AM, Ralph Goers <ra...@dslextreme.com>
wrote:

> The equivalent of the LoggingEvent is an internal part of the Log4j 2
> core. Can you explain what you are trying to do?
>
> Ralph
>
> On Apr 9, 2015, at 8:59 PM, Chathura Priyankara <pr...@gmail.com>
> wrote:
>
> Hi,
>
> I'm trying to upgrade Log4j 1.2.17 to Log4j 2.2. First I tried to do this
> using Log4j 1.x bridge as mentioned in [1], but I couldn't find a way to
> use LoggingEvent with log4j 2.2.
> In Log4j 2.x LoggingEvent is removed or I'm missing something ?
> Is there something similar to LoggingEvent in the new version ?
>
> [1] https://logging.apache.org/log4j/2.x/manual/migration.html
>
> Thanks,
> Best Regards,
> Chathura.
>
> --
> Chathura Priyankara,
> Faculty of Information Technology,
> University of Moratuwa.
> Blog  : www.codeoncloud.blogspot.com
>
>


-- 
Chathura Priyankara,
Faculty of Information Technology,
University of Moratuwa.
Blog  : www.codeoncloud.blogspot.com

Re: [Dev][log4j] Log4j 2.x LoggingEvent is not supported

Posted by Ralph Goers <ra...@dslextreme.com>.
The equivalent of the LoggingEvent is an internal part of the Log4j 2 core. Can you explain what you are trying to do?

Ralph

> On Apr 9, 2015, at 8:59 PM, Chathura Priyankara <pr...@gmail.com> wrote:
> 
> Hi,
> 
> I'm trying to upgrade Log4j 1.2.17 to Log4j 2.2. First I tried to do this using Log4j 1.x bridge as mentioned in [1], but I couldn't find a way to use LoggingEvent with log4j 2.2. 
> In Log4j 2.x LoggingEvent is removed or I'm missing something ?
> Is there something similar to LoggingEvent in the new version ?
> 
> [1] https://logging.apache.org/log4j/2.x/manual/migration.html
> 
> Thanks,
> Best Regards,
> Chathura.
> 
> -- 
> Chathura Priyankara,
> Faculty of Information Technology,
> University of Moratuwa.
> Blog  : www.codeoncloud.blogspot.com