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 <priyankara...@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 <ralph.go...@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 <priyankara...@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.go...@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 <priyankara...@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