
Hello logback users, When trying out perf4j's recently added support for logback I followed example from perf4j logback package javadoc which can be found here: http://perf4j.codehaus.org/apidocs/index.html?org/perf4j/logback/package-sum... That example at the moment has a bug, perf4jFileAppender is referenced from a logger, but the appender is listed in configuration file after logger. Logback's AppenderRefAction reports this as an error with following code {code} ... Appender appender = (Appender) appenderBag.get(appenderName); if (appender == null) { String msg = "Could not find an appender named [" + appenderName + "]. Did you define it below in the config file?"; inError = true; addError(msg); addError("See " + CoreConstants.CODES_URL + "#appender_order for more details."); return; } ... {code} Url this produces in logback-classic 0.9.30 is http://logback.qos.ch/codes.html#appender_order When accessed, error codes page opens, but on it there is no explanation for this error and in the page source there is no element with appender_order id. Couldn't find in the history of the codes.html page ( https://github.com/ceki/logback/commits/master/logback-site/src/site/pages/c... ) one revision that ever had this. Am I missing something or is this a bug in logback site? Regards, Stevo.

Hello, I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file) I dont have any logback.xml in my classpath. My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...) I mean the same way logback init itself with logback.xml at startup Thanks

I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener<http://download.oracle.com/javaee/6/api/javax/servlet/ServletContextListener.html>, it's your best bet. (*Chris*) On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com>wrote:
Hello,
I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file)
I dont have any logback.xml in my classpath.
My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...)
I mean the same way logback init itself with logback.xml at startup
Thanks
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

And if it's a command line tool, just initialise log back manually before you create any loggers. (Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.) David On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote:
I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*)
On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello,
I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file)
I dont have any logback.xml in my classpath.
My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...)
I mean the same way logback init itself with logback.xml at startup
Thanks
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Hello David, sorry about it, My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever. My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other. is that possible ? If i use a logback.xml i see that logback is always the firt launched. so how can i do the same Thanks CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application And if it's a command line tool, just initialise log back manually before you create any loggers. (Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.) David On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote: I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*) On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello, I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file) I dont have any logback.xml in my classpath. My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...) I mean the same way logback init itself with logback.xml at startup Thanks _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

I'm not aware of a single method that will always work regardless of application type. I can't even see how that might work. A web app is very different from a Swing app, which is very different from a command line app, which is light-years from an Android app. The mechanisms are pretty application type specific. (*Chris*) On Fri, Oct 21, 2011 at 2:03 PM, BAKHTI Mohammed <onlymed@hotmail.com>wrote:
Hello David, sorry about it,
My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever.
My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other.
is that possible ?
If i use a logback.xml i see that logback is always the firt launched. so how can i do the same
Thanks ------------------------------ CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100
To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
And if it's a command line tool, just initialise log back manually before you create any loggers.
(Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.)
David
On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote:
I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener<http://download.oracle.com/javaee/6/api/javax/servlet/ServletContextListener.html>, it's your best bet. (*Chris*)
On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com>wrote:
Hello,
I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file)
I dont have any logback.xml in my classpath.
My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...)
I mean the same way logback init itself with logback.xml at startup
Thanks
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

You have to expose a method from your api and get the application to all it before it does any logging. David On 21 Oct 2011, at 22:03, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
Hello David, sorry about it,
My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever.
My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other.
is that possible ?
If i use a logback.xml i see that logback is always the firt launched. so how can i do the same
Thanks CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
And if it's a command line tool, just initialise log back manually before you create any loggers.
(Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.)
David
On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote:
I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*)
On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello,
I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file)
I dont have any logback.xml in my classpath.
My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...)
I mean the same way logback init itself with logback.xml at startup
Thanks
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

That what i have done, but all the framworks like spring, axis2, hibernate are launched before so i lost their logs From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 13:55:47 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application You have to expose a method from your api and get the application to all it before it does any logging. David On 21 Oct 2011, at 22:03, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello David, sorry about it, My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever. My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other. is that possible ? If i use a logback.xml i see that logback is always the firt launched. so how can i do the same Thanks CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application And if it's a command line tool, just initialise log back manually before you create any loggers. (Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.) David On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote: I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*) On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello, I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file) I dont have any logback.xml in my classpath. My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...) I mean the same way logback init itself with logback.xml at startup Thanks _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

How are they launched? I use spring and hibernate etc, but my main method is in a class with no imports from spring or logback. I do my own setup, the initialise logback (just by setting system properties in my case) the I call into spring. Can you do the same? David On 22 Oct 2011, at 19:08, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
That what i have done, but all the framworks like spring, axis2, hibernate are launched before so i lost their logs
From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 13:55:47 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
You have to expose a method from your api and get the application to all it before it does any logging.
David
On 21 Oct 2011, at 22:03, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
Hello David, sorry about it,
My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever.
My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other.
is that possible ?
If i use a logback.xml i see that logback is always the firt launched. so how can i do the same
Thanks CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
And if it's a command line tool, just initialise log back manually before you create any loggers.
(Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.)
David
On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote:
I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*)
On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello,
I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file)
I dont have any logback.xml in my classpath.
My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...)
I mean the same way logback init itself with logback.xml at startup
Thanks
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

thanks David, Can you give me a sample code you use, or more details ? Thanks From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 22:14:01 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application How are they launched? I use spring and hibernate etc, but my main method is in a class with no imports from spring or logback. I do my own setup, the initialise logback (just by setting system properties in my case) the I call into spring. Can you do the same? David On 22 Oct 2011, at 19:08, BAKHTI Mohammed <onlymed@hotmail.com> wrote: That what i have done, but all the framworks like spring, axis2, hibernate are launched before so i lost their logs From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 13:55:47 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application You have to expose a method from your api and get the application to all it before it does any logging. David On 21 Oct 2011, at 22:03, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello David, sorry about it, My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever. My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other. is that possible ? If i use a logback.xml i see that logback is always the firt launched. so how can i do the same Thanks CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application And if it's a command line tool, just initialise log back manually before you create any loggers. (Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.) David On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote: I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*) On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello, I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file) I dont have any logback.xml in my classpath. My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...) I mean the same way logback init itself with logback.xml at startup Thanks _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Ok ... static void main() { readCommandLineArgs(); initLogging(); initSpringContext(); } For a better example of how to call spring from you main method see the spring documentation. David On 22 Oct 2011, at 22:34, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
thanks David,
Can you give me a sample code you use, or more details ?
Thanks
From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 22:14:01 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
How are they launched? I use spring and hibernate etc, but my main method is in a class with no imports from spring or logback. I do my own setup, the initialise logback (just by setting system properties in my case) the I call into spring.
Can you do the same?
David
On 22 Oct 2011, at 19:08, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
That what i have done, but all the framworks like spring, axis2, hibernate are launched before so i lost their logs
From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 13:55:47 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
You have to expose a method from your api and get the application to all it before it does any logging.
David
On 21 Oct 2011, at 22:03, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
Hello David, sorry about it,
My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever.
My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other.
is that possible ?
If i use a logback.xml i see that logback is always the firt launched. so how can i do the same
Thanks CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
And if it's a command line tool, just initialise log back manually before you create any loggers.
(Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.)
David
On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote:
I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*)
On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello,
I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file)
I dont have any logback.xml in my classpath.
My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...)
I mean the same way logback init itself with logback.xml at startup
Thanks
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Yes but that will not help me a lot : My original question was about logback how it can always starts first whatever is the context (webapp, command line...) means if i put a logback.xml in my classpath in a webapp i dont need to start a servlet or anything, logback will init alone. So if i can understund how it can starts i can do the same . Thanks David From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 23:01:05 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application Ok ... static void main() { readCommandLineArgs(); initLogging(); initSpringContext();} For a better example of how to call spring from you main method see the spring documentation. David On 22 Oct 2011, at 22:34, BAKHTI Mohammed <onlymed@hotmail.com> wrote: thanks David, Can you give me a sample code you use, or more details ? Thanks From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 22:14:01 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application How are they launched? I use spring and hibernate etc, but my main method is in a class with no imports from spring or logback. I do my own setup, the initialise logback (just by setting system properties in my case) the I call into spring. Can you do the same? David On 22 Oct 2011, at 19:08, BAKHTI Mohammed <onlymed@hotmail.com> wrote: That what i have done, but all the framworks like spring, axis2, hibernate are launched before so i lost their logs From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 13:55:47 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application You have to expose a method from your api and get the application to all it before it does any logging. David On 21 Oct 2011, at 22:03, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello David, sorry about it, My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever. My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other. is that possible ? If i use a logback.xml i see that logback is always the firt launched. so how can i do the same Thanks CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application And if it's a command line tool, just initialise log back manually before you create any loggers. (Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.) David On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote: I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*) On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello, I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file) I dont have any logback.xml in my classpath. My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...) I mean the same way logback init itself with logback.xml at startup Thanks _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Logback will initialise the first time you retrieve a logger from LoggerFactory. If you want it to initialise before anything else you need to take responsibility for retrieving a Logger before anything else runs. How you do this will depend on what kind of application you are creating - it will not, and cannot, be the same between a web app and a cli. If you tell us precisely what kind of application you are trying to write we can give precise advice. Bear in mind that a static call to LoggerFactory.getLogger() will occur the moment a class is loaded. On 24 Oct 2011, at 09:16, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
Yes but that will not help me a lot :
My original question was about logback how it can always starts first whatever is the context (webapp, command line...) means if i put a logback.xml in my classpath in a webapp i dont need to start a servlet or anything, logback will init alone.
So if i can understund how it can starts i can do the same .
Thanks David
From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 23:01:05 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
Ok ...
static void main() { readCommandLineArgs(); initLogging(); initSpringContext(); }
For a better example of how to call spring from you main method see the spring documentation.
David
On 22 Oct 2011, at 22:34, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
thanks David,
Can you give me a sample code you use, or more details ?
Thanks
From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 22:14:01 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
How are they launched? I use spring and hibernate etc, but my main method is in a class with no imports from spring or logback. I do my own setup, the initialise logback (just by setting system properties in my case) the I call into spring.
Can you do the same?
David
On 22 Oct 2011, at 19:08, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
That what i have done, but all the framworks like spring, axis2, hibernate are launched before so i lost their logs
From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 13:55:47 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
You have to expose a method from your api and get the application to all it before it does any logging.
David
On 21 Oct 2011, at 22:03, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
Hello David, sorry about it,
My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever.
My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other.
is that possible ?
If i use a logback.xml i see that logback is always the firt launched. so how can i do the same
Thanks CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
And if it's a command line tool, just initialise log back manually before you create any loggers.
(Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.)
David
On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote:
I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*)
On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello,
I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file)
I dont have any logback.xml in my classpath.
My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...)
I mean the same way logback init itself with logback.xml at startup
Thanks
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Mohammed, It sounds like you want logback to call you own initializer on startup. I don't know if that's supported out of the box. But perhaps you could look into how it could be implemented. Perhaps in logback.xml you could name your own initialiser class, and logback would call it at some point in it's start up sequence. David On 24 Oct 2011, at 09:21, Robert Elliot <rob@lidalia.org.uk> wrote:
Logback will initialise the first time you retrieve a logger from LoggerFactory.
If you want it to initialise before anything else you need to take responsibility for retrieving a Logger before anything else runs.
How you do this will depend on what kind of application you are creating - it will not, and cannot, be the same between a web app and a cli.
If you tell us precisely what kind of application you are trying to write we can give precise advice.
Bear in mind that a static call to LoggerFactory.getLogger() will occur the moment a class is loaded.
On 24 Oct 2011, at 09:16, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
Yes but that will not help me a lot :
My original question was about logback how it can always starts first whatever is the context (webapp, command line...) means if i put a logback.xml in my classpath in a webapp i dont need to start a servlet or anything, logback will init alone.
So if i can understund how it can starts i can do the same .
Thanks David
From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 23:01:05 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
Ok ...
static void main() { readCommandLineArgs(); initLogging(); initSpringContext(); }
For a better example of how to call spring from you main method see the spring documentation.
David
On 22 Oct 2011, at 22:34, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
thanks David,
Can you give me a sample code you use, or more details ?
Thanks
From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 22:14:01 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
How are they launched? I use spring and hibernate etc, but my main method is in a class with no imports from spring or logback. I do my own setup, the initialise logback (just by setting system properties in my case) the I call into spring.
Can you do the same?
David
On 22 Oct 2011, at 19:08, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
That what i have done, but all the framworks like spring, axis2, hibernate are launched before so i lost their logs
From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 13:55:47 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
You have to expose a method from your api and get the application to all it before it does any logging.
David
On 21 Oct 2011, at 22:03, BAKHTI Mohammed <onlymed@hotmail.com> wrote:
Hello David, sorry about it,
My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever.
My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other.
is that possible ?
If i use a logback.xml i see that logback is always the firt launched. so how can i do the same
Thanks CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application
And if it's a command line tool, just initialise log back manually before you create any loggers.
(Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.)
David
On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote:
I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*)
On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello,
I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file)
I dont have any logback.xml in my classpath.
My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...)
I mean the same way logback init itself with logback.xml at startup
Thanks
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Thanks, That means if i'm in webapp : i have to use ServletListener Otherwise the user has to call my API.getInstance() before anything Do you see anything else must I be aware of ? Thanks From: rob@lidalia.org.uk Date: Mon, 24 Oct 2011 09:21:50 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application Logback will initialise the first time you retrieve a logger from LoggerFactory. If you want it to initialise before anything else you need to take responsibility for retrieving a Logger before anything else runs. How you do this will depend on what kind of application you are creating - it will not, and cannot, be the same between a web app and a cli. If you tell us precisely what kind of application you are trying to write we can give precise advice. Bear in mind that a static call to LoggerFactory.getLogger() will occur the moment a class is loaded. On 24 Oct 2011, at 09:16, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Yes but that will not help me a lot : My original question was about logback how it can always starts first whatever is the context (webapp, command line...) means if i put a logback.xml in my classpath in a webapp i dont need to start a servlet or anything, logback will init alone. So if i can understund how it can starts i can do the same . Thanks David From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 23:01:05 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application Ok ... static void main() { readCommandLineArgs(); initLogging(); initSpringContext();} For a better example of how to call spring from you main method see the spring documentation. David On 22 Oct 2011, at 22:34, BAKHTI Mohammed <onlymed@hotmail.com> wrote: thanks David, Can you give me a sample code you use, or more details ? Thanks From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 22:14:01 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application How are they launched? I use spring and hibernate etc, but my main method is in a class with no imports from spring or logback. I do my own setup, the initialise logback (just by setting system properties in my case) the I call into spring. Can you do the same? David On 22 Oct 2011, at 19:08, BAKHTI Mohammed <onlymed@hotmail.com> wrote: That what i have done, but all the framworks like spring, axis2, hibernate are launched before so i lost their logs From: nabble@diroussel.xsmail.com Date: Sat, 22 Oct 2011 13:55:47 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application You have to expose a method from your api and get the application to all it before it does any logging. David On 21 Oct 2011, at 22:03, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello David, sorry about it, My question is in general : as i do a code based configuration using Joran configurator : if i have some frameworks in my applications (a webapp or a jar ....) . those frameworks will init before my api, so they will send some logs to stdout or whatever. My goal : is how can i be sure that my api (which use logback ) is always initialized firt before all the other. is that possible ? If i use a logback.xml i see that logback is always the firt launched. so how can i do the same Thanks CC: logback-user@qos.ch From: nabble@diroussel.xsmail.com Date: Fri, 21 Oct 2011 21:15:45 +0100 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application And if it's a command line tool, just initialise log back manually before you create any loggers. (Mohammed: please create a new email for a new thread. Don't just reply to an existing thread and change the subject, most email software treats it as the same thread.) David On 21 Oct 2011, at 17:57, Chris Pratt <thechrispratt@gmail.com> wrote: I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*) On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello, I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file) I dont have any logback.xml in my classpath. My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...) I mean the same way logback init itself with logback.xml at startup Thanks _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

On 24 Oct 2011, at 09:22, Robert Elliot <rob@lidalia.org.uk> wrote:
Bear in mind that a static call to LoggerFactory.getLogger() will occur the moment a class is loaded.
This was poorly phrased - what I meant was that if a class contains a static field initialised by a call to LoggerFactory.getLogger() then Logback will be initialised the moment that class is loaded (if it wasn't initialised already).

Hello Chris, and thanks for your reply actually i'm talking in general, if we have a webapp , a jar or other logback is always the first thing launched, so i'm asking about how ? this way i can do the same with my API. Thanks From: thechrispratt@gmail.com Date: Fri, 21 Oct 2011 09:57:01 -0700 To: logback-user@qos.ch Subject: Re: [logback-user] How to start my logback before anything in an application I assume you're talking about a Web Application. If so, check out javax.servlet.ServletContextListener, it's your best bet. (*Chris*) On Fri, Oct 21, 2011 at 7:47 AM, BAKHTI Mohammed <onlymed@hotmail.com> wrote: Hello, I have actually an API which use logback and add some specific functions. this API initialize logback in code : joranConfigurator(myconfig.file) I dont have any logback.xml in my classpath. My question is how can i start this API (and then logback) at application startup before all the other frameworks and APIs (spring, hibernate, axis...) I mean the same way logback init itself with logback.xml at startup Thanks _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Hi Stevo, Thanks for pointing out this omission in the "codes" page. I just corrected it in http://github.com/ceki/logback/commit/1c1e6e5b44a7f . By the way, I am glad perf4j now supports perf4j. Please let us know when the new version of perf4j is released so that we can add link to perf4j from the logback site. Cheers, -- Ceki http://twitter.com/#!/ceki On 21/10/2011 4:18 AM, Stevo Slavić wrote:
Hello logback users,
When trying out perf4j's recently added support for logback I followed example from perf4j logback package javadoc which can be found here: http://perf4j.codehaus.org/apidocs/index.html?org/perf4j/logback/package-sum...
That example at the moment has a bug, perf4jFileAppender is referenced from a logger, but the appender is listed in configuration file after logger. Logback's AppenderRefAction reports this as an error with following code
{code} ... Appender appender = (Appender) appenderBag.get(appenderName);
if (appender == null) { String msg = "Could not find an appender named [" + appenderName + "]. Did you define it below in the config file?"; inError = true; addError(msg); addError("See " + CoreConstants.CODES_URL + "#appender_order for more details."); return; } ... {code}
Url this produces in logback-classic 0.9.30 is http://logback.qos.ch/codes.html#appender_order When accessed, error codes page opens, but on it there is no explanation for this error and in the page source there is no element with appender_order id. Couldn't find in the history of the codes.html page ( https://github.com/ceki/logback/commits/master/logback-site/src/site/pages/c... ) one revision that ever had this.
Am I missing something or is this a bug in logback site?
Regards, Stevo.

Hello Ceki, Thank you for correcting this, I guess it will be later available when site gets published again. perf4j release which supports logback is already available, http://repo1.maven.org/maven2/org/perf4j/perf4j/0.9.16/ Note there is perf4j package with logback-only support, and package with all logging frameworks supported. Just that example in perf4j's logback package javadoc is invalid, I've created a pull request with the fix ( https://github.com/perf4j/perf4j/pull/4 ) and reported issue in perf4j JIRA ( http://jira.codehaus.org/browse/PERFFORJ-60 ) Regards, Stevo. On Fri, Oct 21, 2011 at 7:21 PM, ceki <ceki@qos.ch> wrote:
Hi Stevo,
Thanks for pointing out this omission in the "codes" page. I just corrected it in http://github.com/ceki/logback/commit/1c1e6e5b44a7f .
By the way, I am glad perf4j now supports perf4j. Please let us know when the new version of perf4j is released so that we can add link to perf4j from the logback site.
Cheers, -- Ceki http://twitter.com/#!/ceki
On 21/10/2011 4:18 AM, Stevo Slavić wrote:
Hello logback users,
When trying out perf4j's recently added support for logback I followed example from perf4j logback package javadoc which can be found here:
http://perf4j.codehaus.org/apidocs/index.html?org/perf4j/logback/package-sum...
That example at the moment has a bug, perf4jFileAppender is referenced from a logger, but the appender is listed in configuration file after logger. Logback's AppenderRefAction reports this as an error with following code
{code} ... Appender appender = (Appender) appenderBag.get(appenderName);
if (appender == null) { String msg = "Could not find an appender named [" + appenderName + "]. Did you define it below in the config file?"; inError = true; addError(msg); addError("See " + CoreConstants.CODES_URL + "#appender_order for more details."); return; } ... {code}
Url this produces in logback-classic 0.9.30 is http://logback.qos.ch/codes.html#appender_order When accessed, error codes page opens, but on it there is no explanation for this error and in the page source there is no element with appender_order id. Couldn't find in the history of the codes.html page (
https://github.com/ceki/logback/commits/master/logback-site/src/site/pages/c... ) one revision that ever had this.
Am I missing something or is this a bug in logback site?
Regards, Stevo.
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

On 21/10/2011 8:15 PM, Stevo Slavić wrote:
Hello Ceki,
Thank you for correcting this, I guess it will be later available when site gets published again.
Yes, indeed.
perf4j release which supports logback is already available, http://repo1.maven.org/maven2/org/perf4j/perf4j/0.9.16/ Note there is perf4j package with logback-only support, and package with all logging frameworks supported.
I already added a link to perf4j from the logback download page. It might take up to 4 hours for all nodes to sync the update.
Just that example in perf4j's logback package javadoc is invalid, I've created a pull request with the fix ( https://github.com/perf4j/perf4j/pull/4 ) and reported issue in perf4j JIRA ( http://jira.codehaus.org/browse/PERFFORJ-60 )
Yep, I've seen it. Cheers, -- Ceki http://twitter.com/#!/ceki
participants (6)
-
BAKHTI Mohammed
-
ceki
-
Chris Pratt
-
David Roussel
-
Robert Elliot
-
Stevo Slavić