You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Rajvinder Pal <ra...@gmail.com> on 2018/08/10 10:29:28 UTC

Multiple Applications writing to same log file

Hi,

Can multiple web applications write to same log file using log4j2 ? Should
i create separate log file for each web application?

Thanks,
Raj

Re: Multiple Applications writing to same log file

Posted by Jochen Wiedmann <jo...@gmail.com>.
On Fri, Aug 10, 2018 at 12:29 PM Rajvinder Pal <ra...@gmail.com> wrote:

> Can multiple web applications write to same log file using log4j2 ? Should
> i create separate log file for each web application?

The easiest solution would be to add the log4j jars to a shared
ClassLoader. (Thus, doing exactly that, what I told you *not* to do,
if you want your configuration per webapp.) OTOH: Are you sure, this
is what you want? I'd rather see things separated.

And, to be sure: My suggestion will most likely not work, if you want
a per webapp configuration for *some* webapps. It's all, or nothing,
in that case.

Jochen

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


Re: Multiple Applications writing to same log file

Posted by Ralph Goers <ra...@dslextreme.com>.
I realize I misread the question. Yes, two web applications running in the same JVM can write to the same log file. If there is only one instance of log4j in the JVM then you should be able to safely use the RollingFileAppender.

Ralph

> On Aug 10, 2018, at 7:38 AM, Ralph Goers <ra...@dslextreme.com> wrote:
> 
> You can have multiple applications write to the same log file if you use file locking, otherwise your log file is likely to get corrupted. The RollingFileAppender does not support file locking as it is not possible, or at least very difficult, to have multiple applications try to safely roll the files. 
> 
> Ralph 
> 
>> On Aug 10, 2018, at 3:29 AM, Rajvinder Pal <ra...@gmail.com> wrote:
>> 
>> Hi,
>> 
>> Can multiple web applications write to same log file using log4j2 ? Should
>> i create separate log file for each web application?
>> 
>> Thanks,
>> Raj
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 



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


Re: Multiple Applications writing to same log file

Posted by Ralph Goers <ra...@dslextreme.com>.
You can have multiple applications write to the same log file if you use file locking, otherwise your log file is likely to get corrupted. The RollingFileAppender does not support file locking as it is not possible, or at least very difficult, to have multiple applications try to safely roll the files. 

Ralph 

> On Aug 10, 2018, at 3:29 AM, Rajvinder Pal <ra...@gmail.com> wrote:
> 
> Hi,
> 
> Can multiple web applications write to same log file using log4j2 ? Should
> i create separate log file for each web application?
> 
> Thanks,
> Raj



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