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 <only...@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: nab...@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 <only...@hotmail.com> wrote: > > thanks David, > > Can you give me a sample code you use, or more details ? > > Thanks > > From: nab...@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 <only...@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: nab...@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 <only...@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: nab...@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 <thechrispr...@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 <only...@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