lfbarragan | 2 Jun 2008 10:59
Picon
Gravatar

Configure multiple log files in single EAR


Hi, I have an EAR that includes a JAR and a WAR and I need to setup a
separate log file for each one. Currently I have a log4j configuration file
for both but when the server is starting the second configuration file is
overriding the first one, so all the log messages are being displayed on the
file defined on the second configuration file.

What should I do to get separate log files for the JAR and the WAR?

Thanks in advance.
--

-- 
View this message in context: http://www.nabble.com/Configure-multiple-log-files-in-single-EAR-tp17596842p17596842.html
Sent from the Log4j - Users mailing list archive at Nabble.com.

[RELATIVE PATHS] Experiencing problems: relative paths are not recognized

Hi there,
I'm experiencing many problems with the log file path while trying to 
use a relative file path. I've got a Web application written in Java and 
powered by Tomcat. The thing is I'm doing my development in a Windows 
machine and so far I've hard-coded the path I want my log file to be 
written. But the application is intended to be deployed in a Linux 
machine and therefore the log file path is bound to change.
So far, I'm writing both paths in my log4j.properties file and 
commenting the one I don't need in each situation:

log4j.appender.Appender.File=C:\\emedica\\SEG_QUIM\\aplicacion\\filesystem\\securequim\\logs\\ADMPAC\\ADMPAC.log
#log4j.appender.Appender.File=/home/securequim/logs/ADMPAC/ADMPAC.log

Now, this is not very practical and I think it could be improved.
The way to improve it, I guess, is by specifying a variable to be used 
in the log4j.properties file, the same as ${cataline.home} or 
${user.home}. Now what I do is the following:

1. I right-click in the Apache Tomcat icon in the notification area of 
Windows and choose "Configure...". I then go to the "Java" tab and in 
the "Java Options", which already contains the following:

-Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 5.0
-Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 
5.0\common\endorsed
-Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 5.0

I add:

-DlogDir=C:\emedica\SEG_QUIM\aplicacion\filesystem\securequim\logs\ADMPAC
(Continue reading)

Curt Arnold | 2 Jun 2008 19:05
Picon
Favicon

Re: [RELATIVE PATHS] Experiencing problems: relative paths are not recognized


On Jun 2, 2008, at 6:01 AM, Jon Haitz Legarreta Gorroño wrote:

> Hi there,
> I'm experiencing many problems with the log file path while trying  
> to use a relative file path. I've got a Web application written in  
> Java and powered by Tomcat. The thing is I'm doing my development in  
> a Windows machine and so far I've hard-coded the path I want my log  
> file to be written. But the application is intended to be deployed  
> in a Linux machine and therefore the log file path is bound to change.
> So far, I'm writing both paths in my log4j.properties file and  
> commenting the one I don't need in each situation:
>
> log4j.appender.Appender.File=C:\\emedica\\SEG_QUIM\\aplicacion\ 
> \filesystem\\securequim\\logs\\ADMPAC\\ADMPAC.log
> #log4j.appender.Appender.File=/home/securequim/logs/ADMPAC/ADMPAC.log
>
> Now, this is not very practical and I think it could be improved.
> The way to improve it, I guess, is by specifying a variable to be  
> used in the log4j.properties file, the same as ${cataline.home} or $ 
> {user.home}. Now what I do is the following:
>
> 1. I right-click in the Apache Tomcat icon in the notification area  
> of Windows and choose "Configure...". I then go to the "Java" tab  
> and in the "Java Options", which already contains the following:
>
> -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 5.0
> -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation 
> \Tomcat 5.0\common\endorsed
> -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat  
(Continue reading)

Jacob Kjome | 3 Jun 2008 07:17
Favicon

Re: Configure multiple log files in single EAR

The only way I can think of that you would have separate logger repositories in an
EAR is if you configure the webapp classloader to be parent-last (e.g.
child-first).  I don't think using a JNDI-based repository selector would
distinguish between the webapp and the jar in the EAR file.  They'd both be part
of the same JNDI tree (I could be wrong - only testing will tell).

Jake

lfbarragan wrote:
> Hi, I have an EAR that includes a JAR and a WAR and I need to setup a
> separate log file for each one. Currently I have a log4j configuration file
> for both but when the server is starting the second configuration file is
> overriding the first one, so all the log messages are being displayed on the
> file defined on the second configuration file.
> 
> What should I do to get separate log files for the JAR and the WAR?
> 
> Thanks in advance.

Re: [RELATIVE PATHS] Experiencing problems: relative paths are not recognized

Hi again,
thanks for your answer Curt, but it did not fix the problem. I'm still 
experiencing the same problems as yesterday.

Any other ideas?

Thank you,
JON HAITZ

Curt Arnold escribió:
>
> On Jun 2, 2008, at 6:01 AM, Jon Haitz Legarreta Gorroño wrote:
>
>> Hi there,
>> I'm experiencing many problems with the log file path while trying to 
>> use a relative file path. I've got a Web application written in Java 
>> and powered by Tomcat. The thing is I'm doing my development in a 
>> Windows machine and so far I've hard-coded the path I want my log 
>> file to be written. But the application is intended to be deployed in 
>> a Linux machine and therefore the log file path is bound to change.
>> So far, I'm writing both paths in my log4j.properties file and 
>> commenting the one I don't need in each situation:
>>
>>
log4j.appender.Appender.File=C:\\emedica\\SEG_QUIM\\aplicacion\\filesystem\\securequim\\logs\\ADMPAC\\ADMPAC.log 
>>
>> #log4j.appender.Appender.File=/home/securequim/logs/ADMPAC/ADMPAC.log
>>
>> Now, this is not very practical and I think it could be improved.
>> The way to improve it, I guess, is by specifying a variable to be 
(Continue reading)

Duseja, Sushil | 3 Jun 2008 13:45
Picon

Logging method name

Hello,

I used event.getLocationInformation().getMethodName() to log the method
name (where event is the LoggingEvent object), but it does not appear to
be correctly logging the method name; it's fetching - '?' instead. Can
anyone please point me to the correct way of doing the same?

It seems as if the LocationInfo object is null. Do I need to set this
object?

Any help is appreciated.

Thanks.

Curt Arnold | 3 Jun 2008 15:30
Picon
Favicon

Re: Logging method name


On Jun 3, 2008, at 6:45 AM, Duseja, Sushil wrote:

> Hello,
>
> I used event.getLocationInformation().getMethodName() to log the  
> method
> name (where event is the LoggingEvent object), but it does not  
> appear to
> be correctly logging the method name; it's fetching - '?' instead. Can
> anyone please point me to the correct way of doing the same?
>
> It seems as if the LocationInfo object is null. Do I need to set this
> object?
>
> Any help is appreciated.
>
> Thanks.
>

Your application could have been compiled without debugging  
information which would result in that behavior.

Also, since construction of a Throwable to collect the stack trace is  
expensive and often not used, it is only constructed on request.   
Since it has to be constructed while on the same thread as the  
original call, the AsyncAppender has a parameter to determine whether  
that info should be collected before the event is placed in a queue to  
be processed by a worker thread.   If you are using an AsyncAppender,  
set locationInfo to true.
(Continue reading)

Jacob Kjome | 3 Jun 2008 16:53
Favicon

Re: [RELATIVE PATHS] Experiencing problems: relative paths are not recognized

On Tue, 03 Jun 2008 09:57:07 +0200
  Jon Haitz Legarreta Gorroño <jhlegarreta <at> vicomtech.org> wrote:
> Hi again,
> thanks for your answer Curt, but it did not fix the problem. I'm still 
>experiencing the same problems as yesterday.
> 
> Any other ideas?

You are saying that the following doesn't work for you?

log4j.appender.Appender.File=${logDir}/ADMPAC.log

That would be really surprising as I use this all the time and it has never 
failed for me.

Jake

> 
> Thank you,
> JON HAITZ
> 
> 
> 
> Curt Arnold escribió:
>>
>> On Jun 2, 2008, at 6:01 AM, Jon Haitz Legarreta Gorroño wrote:
>>
>>> Hi there,
>>> I'm experiencing many problems with the log file path while trying to 
>>> use a relative file path. I've got a Web application written in Java 
(Continue reading)

Maarten Bosteels | 3 Jun 2008 20:59
Picon

Re: Configure multiple log files in single EAR

It's easy IF you can make sure that the names of the loggers in the
jar don't collide with the names of the loggers in the war.

Suppose all loggers in the jar start with "com.example.jar." and all
loggers in the war start with "com.example.jar."
then you just have to configure two different file-appenders and link
them to the respective logger hierarchy.

Of course, this could be hard to accomplish when your jar and war are
both using the same libraries, and when these libraries have fixed
logger-names.

Maarten

On Tue, Jun 3, 2008 at 7:17 AM, Jacob Kjome <hoju <at> visi.com> wrote:
> The only way I can think of that you would have separate logger repositories in an
> EAR is if you configure the webapp classloader to be parent-last (e.g.
> child-first).  I don't think using a JNDI-based repository selector would
> distinguish between the webapp and the jar in the EAR file.  They'd both be part
> of the same JNDI tree (I could be wrong - only testing will tell).
>
> Jake
>
> lfbarragan wrote:
>> Hi, I have an EAR that includes a JAR and a WAR and I need to setup a
>> separate log file for each one. Currently I have a log4j configuration file
>> for both but when the server is starting the second configuration file is
>> overriding the first one, so all the log messages are being displayed on the
>> file defined on the second configuration file.
>>
(Continue reading)

James A. N. Stauffer | 3 Jun 2008 22:01
Picon
Gravatar

Re: Various fields in log4j.properties

You might for the XML DTD helpful (but I don't know if there is a spec
for .properties)
http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/resources/org/apache/log4j/xml/log4j.dtd?view=markup

On Thu, May 8, 2008 at 1:02 AM, lp_1431 <pl.teenup <at> gmail.com> wrote:
>
> Kindly please let me know all the fields that can be put in the
> log4j.properties file.
>
> Thanks
>
> --
> View this message in context: http://www.nabble.com/Various-fields-in-log4j.properties-tp17120176p17120176.html
> Sent from the Log4j - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe <at> logging.apache.org
> For additional commands, e-mail: log4j-user-help <at> logging.apache.org
>
>

--

-- 
James A. N. Stauffer http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

Gmane