What platform are you using? it used to work for me on windows... On Sun, Sep 11, 2016 at 4:16 PM, Juan Fuentes <[email protected]> wrote:
> I did copy paste the examples, so those where included. > > java -cp log4j-core-2.6.2.jar > org.apache.logging.log4j.core.tools.Generate$CustomLogger > MyLogger > MyLogger.java > > I tried having MyLogger in both a package and base package and also > outputting the source to console or a file. > > Juan > > > On 11 Sep 2016, at 09:13, Remko Popma <[email protected]> wrote: > > > > You need to run either Generate$ExtendedLogger or Generate$CustomLogger. > > Generate does not have a main method. > > > > On Sun, Sep 11, 2016 at 4:10 PM, Juan Fuentes < > [email protected]> > > wrote: > > > >> As I side note, I tried to use that tool this morning to see the code > that > >> generates, and it fails to me using the examples. > >> > >> Error: Main method not found in class org.apache.logging.log4j.core. > tools.Generate, > >> please define the main method as: > >> public static void main(String[] args) > >> or a JavaFX application class must extend javafx.application.Application > >> > >> Juan > >> > >> > >> > >>> On 11 Sep 2016, at 08:50, Remko Popma <[email protected]> wrote: > >>> > >>> The focus of that logger wrapper generator is on the convenience > methods > >> to > >>> generate for a new log level, that is why the tools is documented under > >>> custom levels. > >>> > >>> This still makes sense to me, but I've seen this question several times > >> now > >>> so you are certainly not the only one who didn't find the docs... > That's > >>> why I'm thinking to add this to the FAQ, but other suggestions are > >> welcome. > >>> > >>> On Sun, Sep 11, 2016 at 3:41 PM, Ralph Goers < > [email protected] > >>> > >>> wrote: > >>> > >>>> I should have looked at your link first. It seems rather odd to find > >>>> custom logger documentation under custom levels, and I didn’t see it > in > >> the > >>>> table of contents - probably because I didn’t think to click on that. > >>>> > >>>> Ralph > >>>> > >>>>> On Sep 10, 2016, at 11:39 PM, Ralph Goers < > [email protected]> > >>>> wrote: > >>>>> > >>>>> Do we have documentation on making custom Loggers? > >>>>> > >>>>> Ralph > >>>>> > >>>>>> On Sep 10, 2016, at 5:09 PM, Remko Popma <[email protected]> > >> wrote: > >>>>>> > >>>>>> The easier way is to use the wrapper generator tool included in > log4j. > >>>> The tool is intended to be used with custom log levels and is > documented > >>>> here: https://logging.apache.org/log4j/2.x/manual/ > customloglevels.html# > >>>> AddingOrReplacingLevels > >>>>>> > >>>>>> I should add this question to the faq page, this is at least the 3rd > >> or > >>>> 4th time this came up. > >>>>>> > >>>>>> Sent from my iPhone > >>>>>> > >>>>>>> On 2016/09/11, at 6:11, Juan Fuentes <[email protected] > > > >>>> wrote: > >>>>>>> > >>>>>>> Thanks Matt and Ralph, > >>>>>>> > >>>>>>> I have extended ExtendedLoggerWrapper and it seems to work. Let’s > >> hope > >>>> I don’t stumble against other peculiarities. > >>>>>>> > >>>>>>> Thanks again! > >>>>>>> Juan > >>>>>>> > >>>>>>>> On 10 Sep 2016, at 21:44, Matt Sicker <[email protected]> wrote: > >>>>>>>> > >>>>>>>> If there's an easier way to do it, that'd be cool, but all the > >>>> bridges in > >>>>>>>> log4j itself use ExtendedLoggerWrapper as it is. > >>>>>>>> > >>>>>>>> On 10 September 2016 at 14:35, Ralph Goers < > >>>> [email protected]> > >>>>>>>> wrote: > >>>>>>>> > >>>>>>>>> Yes, you use ExtendedLoggerWrapper and pass the fully qualified > >>>> class name > >>>>>>>>> of your wrapper class on the logMessage call. I seem to recall > >> there > >>>> is an > >>>>>>>>> even easier way but it escapes me and I don’t see it documented > on > >>>> the web > >>>>>>>>> site. > >>>>>>>>> > >>>>>>>>> Ralph > >>>>>>>>> > >>>>>>>>>> On Sep 10, 2016, at 12:06 PM, Matt Sicker <[email protected]> > >> wrote: > >>>>>>>>>> > >>>>>>>>>> I should note that you might want to use ExtendedLoggerWrapper > in > >>>> this > >>>>>>>>>> scenario as the methods are protected otherwise that I just > >>>> mentioned. > >>>>>>>>>> > >>>>>>>>>>> On 10 September 2016 at 14:03, Matt Sicker <[email protected]> > >>>> wrote: > >>>>>>>>>>> > >>>>>>>>>>> When you make a custom Logger wrapper, you need to use the > >>>> logMessage() > >>>>>>>>>>> methods that include the fqcn string which should be the fully > >>>> qualified > >>>>>>>>>>> class name of the logger wrapper. See AbstractLogger for an > >>>> example. > >>>>>>>>>>> > >>>>>>>>>>> On 10 September 2016 at 13:57, Juan Fuentes < > >>>>>>>>> [email protected]> > >>>>>>>>>>> wrote: > >>>>>>>>>>> > >>>>>>>>>>>> Dear all, > >>>>>>>>>>>> > >>>>>>>>>>>> After spending half a day on this I have decide to try luck on > >> the > >>>>>>>>>>>> official mailing list, hopefully some dev can throw some light > >>>> over > >>>>>>>>> this. > >>>>>>>>>>>> > >>>>>>>>>>>> I’m trying to use a wrapper over a Logger object to restrict > the > >>>>>>>>> methods > >>>>>>>>>>>> of the API to the ones on my interface, for example: > >>>>>>>>>>>> > >>>>>>>>>>>> class Log4JLogger implements com.opencms.core.logging.Logger > { > >>>>>>>>>>>> > >>>>>>>>>>>> private Logger logger; > >>>>>>>>>>>> > >>>>>>>>>>>> public Log4JLogger(Logger logger) { > >>>>>>>>>>>> this.logger = logger; > >>>>>>>>>>>> } > >>>>>>>>>>>> > >>>>>>>>>>>> @Override > >>>>>>>>>>>> public void traceEntry(String message, Object... args) { > >>>>>>>>>>>> this.logger.traceEntry(message, args); > >>>>>>>>>>>> } > >>>>>>>>>>>> > >>>>>>>>>>>> If I combine this with a pattern that includes the line and > the > >>>> method > >>>>>>>>>>>> name, for example: > >>>>>>>>>>>> <PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} %-5level > >>>> %class{36} > >>>>>>>>> %L > >>>>>>>>>>>> %M - %msg%xEx%n"/> > >>>>>>>>>>>> > >>>>>>>>>>>> I get as result the line and method name on the wrapper, what > >>>> makes > >>>>>>>>>>>> sense, but is not what I want to. I want the ones from the > class > >>>> that > >>>>>>>>> calls > >>>>>>>>>>>> the wrapper. > >>>>>>>>>>>> > >>>>>>>>>>>> Any way to configure/specify this in any way? > >>>>>>>>>>>> > >>>>>>>>>>>> I would be also happy if I can just extend a Logger and > >> implement > >>>> my > >>>>>>>>>>>> interface on it, but what logger should I extend? How can I > >>>> create an > >>>>>>>>>>>> instance of this custom logger afterwards? > >>>>>>>>>>>> > >>>>>>>>>>>> Thanks in advance, > >>>>>>>>>>>> Juan > >>>>>>>>>>>> ------------------------------------------------------------ > >>>> --------- > >>>>>>>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@ > >> logging.apache.org > >>>>>>>>>>>> For additional commands, e-mail: log4j-user-help@logging. > >>>> apache.org > >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> -- > >>>>>>>>>>> Matt Sicker <[email protected]> > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> -- > >>>>>>>>>> Matt Sicker <[email protected]> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> ------------------------------------------------------------ > >>>> --------- > >>>>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@ > logging.apache.org > >>>>>>>>> For additional commands, e-mail: log4j-user-help@logging. > >> apache.org > >>>>>>>> > >>>>>>>> > >>>>>>>> -- > >>>>>>>> Matt Sicker <[email protected]> > >>>>>>> > >>>>>>> > >>>>>>> ------------------------------------------------------------ > >> --------- > >>>>>>> To unsubscribe, e-mail: [email protected] > >>>>>>> For additional commands, e-mail: log4j-user-help@logging. > apache.org > >>>>>>> > >>>>>> > >>>>>> ------------------------------------------------------------ > --------- > >>>>>> To unsubscribe, e-mail: [email protected] > >>>>>> For additional commands, e-mail: [email protected] > >>>>>> > >>>>>> > >>>>> > >>>>> > >>>>> > >>>>> ------------------------------------------------------------ > --------- > >>>>> To unsubscribe, e-mail: [email protected] > >>>>> For additional commands, e-mail: [email protected] > >>>>> > >>>>> > >>>> > >>>> > >>>> > >>>> --------------------------------------------------------------------- > >>>> To unsubscribe, e-mail: [email protected] > >>>> For additional commands, e-mail: [email protected] > >>>> > >>>> > >> > >> > >
