logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacob Kjome" <h...@visi.com>
Subject Re: Separating some classes' messages from <root>
Date Thu, 24 Feb 2011 17:26:19 GMT

-Dlog4j.defaultInitOverride=true
-Dlog4j.configuration=file:/url/path/to/log4j.xml

See more at...
http://logging.apache.org/log4j/1.2/manual.html#defaultInit


Jake

On Thu, 24 Feb 2011 12:14:18 -0500
 "Mikhail T." <mi+thun@aldan.algebra.com> wrote:
> On 24.02.2011 10:49, Jacob Kjome wrote:
>> Seems to me that Log4j is just setting up the Root logger defined in the 
>>config file, which references the SERVERLOG appender and, therefore, 
>>configures said appender.
>>
>> It is only coincidence that this has anything to do with the 
>>"org.serviio.console.ServiioConsole" class performing logging.  Apparently, 
>>this is the first logger to be called and since Log4j was not yet configured, 
>>it configures itself using the log4j.xml config file.
>>
>> Your problem is that the root logger is referencing an appender, which 
>>points to a file that the user running your application has no permission to 
>>create.  This has nothing whatsoever to do with additivity.  Your config is 
>>fine.  Your user's file system permissions need tweaking (or you need to 
>>point to a different file system location in your config). 
> Thank you very much, Jacob, for the analysis. Here is some more 
>information...
> 
> The application I'm dealing with -- serviio <http://www.serviio.org/> -- 
>consists of two parts: the server daemon and the GUI console. As distributed 
>by the author, they share some settings, including the log4j.xml file.
> 
> The daemon-part starts automatically at boot and runs under its own user-ID. 
>I want the daemon's log-messages in the log-file.
> 
> The console-piece can be started by any local user of the system -- and no 
>such user should be able to write to the server's log -- hence the 
>restrictive permissions... I want the console's log-messages to go to stderr 
>only, as is normal for interactive programs.
> 
> There are only two log4j-using classes used by the console, so it was 
>practical to enumerate them explicitly sending all their entries to stderr. 
>The catch-all Root-logger would not be used by the console at all -- or so I 
>thought... I'd consider it a bug, that the files referenced by the 
>file-appenders are opened /in advance/ instead of, /lazily/ -- when needed -- 
>which in this case would be never.
> 
> If there is no setting to tell log4j to postpone opening the files until 
>there is an actual message ready to be written there, I guess, my only option 
>is to have two distinct configuration files -- one for each piece of the 
>application... Is there a way to specify an alternative file (rather than the 
>default log4j.xml) on command-line with an environment variable or 
>-D/something/? Or must I create a separate directory for the different 
>log4j.xml? Thanks! Yours,
> 
>    -mi
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message