You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Martyn Hiemstra <m....@minihouse.com> on 2007/10/16 12:42:01 UTC
Tomcat Commons logging and log4j
Hi All,
I have been working with tomcat and log4j for a while and it worked
perfectly. Now I have updated all my web apps to use commons logging. I
have discovered that the Tomcat developers have absolutly no idea how to
do something right when it comes to commons logging and I am curious to why.
I tried tomcat 5.028 and commons logging. I discovered that tomcat used
it's own commons-logging-api.jar file and it was impossible to override
this commons logging file.
I am running tomcat 6 now and I have discovered that tomcat 6 uses
commons logging without log4j enabled.
I have log4j.jar and commons-logging-1.1.jar in my webapp\WEB-INF\lib
directory and I put my log4j.properties file in the
webapp\WEB-INF\classes ditrectory so this should be correct. If I create
a FileAppender like this:
log4j.appender.fileout=org.apache.log4j.RollingFileAppender
log4j.appender.fileout.File=/tmp/myLog.log
log4j.appender.fileout.MaxFileSize=1024KB
log4j.appender.fileout.MaxBackupIndex=1
log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.conversionPattern=[%-6p] %-13d{ABSOLUTE}
%-26C{1} %-4L %m%n
I have discovered that the /tmp/myLog.log is created but nothing is
outputed to this file.
I am curious, why have the tomcat developers disabled something that is
so commonly used?
Thanks in advance,
Martyn
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat Commons logging and log4j
Posted by Martyn Hiemstra <m....@minihouse.com>.
Hi Pid,
Thanks for all your answers. Since I have been working on this problem
for some while I will give it a break for a few days and then continue
again with a fresh view. I'll look over everything, this time assuming
the error is on my behalf. When I round up the points you have stated:
* have you set a logging level that will permit log messages to be
written to the file?
* what attributes are set in your application context configuration?
E.g. is the swallowOutput="true" attribute set?
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
and the error still exists I shall email this list again. Thanks for
time and patience.
Martyn
> Martyn Hiemstra wrote:
>
>> Hi Pid,
>>
>> Thanks for your response. Please forgive my initial response. After
>> reading so much about how JCL isnt working correctly under Tomcat I was
>> getting frustrated. Having to spend 2 days getting it to work without
>> success is for every programmer frustrating.
>>
>> I found this website: http://tomcat.apache.org/tomcat-6.0-doc/logging.html
>> It states that you need to activate it by building something first. This
>> means it isnt enabled be default.
>>
>
> "By default, only java.util.logging is available for the core Tomcat"
> The key word there is "core".
>
> I'm assuming that you want to use log4j for your *application* logging,
> not to log internal Tomcat server activity. If so, you can safely
> ignore the references above as they do not apply to your situation.
>
>
>> I even found a website where a person stated that anybody using JCL with
>> tomcat are just plain stupid. Here is the link:
>> http://www.bileblog.org/?p=259
>>
>
> It's a rant, ignore it.
>
>
>> These blogs/forums also indicate problems with tomcat and JCL:
>> http://www.oreillynet.com/onjava/blog/2006/08/tomcat_5x_commons_logging_and.html
>>
>
> Again, n/a if you're using Tomcat 6.
>
>
>> http://java2.5341.com/msg/96959.html
>>
>
> This seems to refer to a classloader issue, and not an internal problem
> with Tomcat.
>
>
>> http://commons.apache.org/logging/commons-logging-1.1/troubleshooting.html#Apache_Tomcat
>>
>
> Again, not applicable. commons-logging-api is NOT commons-logging, and
> the apache docs even go on to explain that putting a later version of
> commons-logging into a webapp classpath is entirely possible and will in
> fact work as advertised because commons-logging-api *does not contain
> any log adapters*.
>
>
>> If so many people are having problems then this must be an error on
>> Tomcat's behalf.
>>
>
> You are yet to demonstrate that there is a problem with Tomcat, or in
> fact the Tomcat is unable to use Log4J. As I stated before, I am
> successfully using JCL and Log4J on a number of servers - as I'm sure
> other lists members are too.
>
>
>
>
>> Also If I use the exact same lib files in the exact
>> same place and the same configuration file but I replace
>> protected final Log log = LogFactory.getLog( class ) (JCL)
>> with
>> protected final Logger logger = Logger.getLogger( class ) (Log4j)
>>
>> it should produce the same logging but it doesnt. When I use JCL no
>> logging occures except to the system output but this is because tomcat
>> uses java.util.Logging and that defaults output to the System.out
>>
>
> (see below)
>
>
>> I hope someone can help out in getting JCL with tomcat and log4j to work.
>>
>
> I am trying to, but you're determined to stick to your faulty assumption
> that there's a fault with Tomcat (which there doesn't appear to be to me).
>
>
> I shall repeat my questions:
>
> * have you set a logging level that will permit log messages to be
> written to the file?
>
> * what attributes are set in your application context configuration?
>
> E.g. is the swallowOutput="true" attribute set?
> http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
>
>
> Answer these, and we'll continue.
>
> p
>
>
>
>
>> Thanks in advance,
>> Martyn
>>
>>
>>
>> Pid schreef:
>>
>>> Martyn Hiemstra wrote:
>>>
>>>
>>>> Hi All,
>>>>
>>>> I have been working with tomcat and log4j for a while and it worked
>>>> perfectly. Now I have updated all my web apps to use commons logging. I
>>>> have discovered that the Tomcat developers have absolutly no idea how to
>>>> do something right when it comes to commons logging and I am curious to
>>>> why.
>>>>
>>>>
>>> Non-specific insults are likely to generate attention, but unlikely to
>>> encourage help. Never-the-less, I will attempt to assist.
>>>
>>>
>>>
>>>> I tried tomcat 5.028 and commons logging. I discovered that tomcat used
>>>> it's own commons-logging-api.jar file and it was impossible to override
>>>> this commons logging file.
>>>>
>>>>
>>> commons-logging-api is not the same as commons-logging
>>>
>>>
>>>
>>>> I am running tomcat 6 now and I have discovered that tomcat 6 uses
>>>> commons logging without log4j enabled.
>>>>
>>>>
>>> log4j is 'enabled' when you configure it and supply the jar file.
>>>
>>>
>>>
>>>> I have log4j.jar and commons-logging-1.1.jar in my webapp\WEB-INF\lib
>>>> directory and I put my log4j.properties file in the
>>>> webapp\WEB-INF\classes ditrectory so this should be correct.
>>>>
>>> Sounds just like the configuration I am using, successfully I might add.
>>>
>>>
>>>
>>>> If I create a FileAppender like this:
>>>>
>>>> log4j.appender.fileout=org.apache.log4j.RollingFileAppender
>>>> log4j.appender.fileout.File=/tmp/myLog.log
>>>> log4j.appender.fileout.MaxFileSize=1024KB
>>>> log4j.appender.fileout.MaxBackupIndex=1
>>>> log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
>>>> log4j.appender.fileout.layout.conversionPattern=[%-6p] %-13d{ABSOLUTE}
>>>> %-26C{1} %-4L %m%n
>>>>
>>>> I have discovered that the /tmp/myLog.log is created but nothing is
>>>> outputed to this file.
>>>>
>>>>
>>> From the obvious questions department:
>>>
>>> * have you set a logging level that will permit log messages to be
>>> written to the file?
>>>
>>> * what attributes are set in your application context configuration?
>>>
>>>
>>>
>>>> I am curious, why have the tomcat developers disabled something that is
>>>> so commonly used?
>>>>
>>>>
>>> It's not disabled, you are probably doing something wrong. Log4J works
>>> perfectly well if it's configured correctly.
>>>
>>> p
>>>
>>>
>>>
>>>
>>>
>>>> Thanks in advance,
>>>> Martyn
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat Commons logging and log4j
Posted by Pid <p...@pidster.com>.
Martyn Hiemstra wrote:
> Hi Pid,
>
> Thanks for your response. Please forgive my initial response. After
> reading so much about how JCL isnt working correctly under Tomcat I was
> getting frustrated. Having to spend 2 days getting it to work without
> success is for every programmer frustrating.
>
> I found this website: http://tomcat.apache.org/tomcat-6.0-doc/logging.html
> It states that you need to activate it by building something first. This
> means it isnt enabled be default.
"By default, only java.util.logging is available for the core Tomcat"
The key word there is "core".
I'm assuming that you want to use log4j for your *application* logging,
not to log internal Tomcat server activity. If so, you can safely
ignore the references above as they do not apply to your situation.
> I even found a website where a person stated that anybody using JCL with
> tomcat are just plain stupid. Here is the link:
> http://www.bileblog.org/?p=259
It's a rant, ignore it.
> These blogs/forums also indicate problems with tomcat and JCL:
> http://www.oreillynet.com/onjava/blog/2006/08/tomcat_5x_commons_logging_and.html
Again, n/a if you're using Tomcat 6.
> http://java2.5341.com/msg/96959.html
This seems to refer to a classloader issue, and not an internal problem
with Tomcat.
> http://commons.apache.org/logging/commons-logging-1.1/troubleshooting.html#Apache_Tomcat
Again, not applicable. commons-logging-api is NOT commons-logging, and
the apache docs even go on to explain that putting a later version of
commons-logging into a webapp classpath is entirely possible and will in
fact work as advertised because commons-logging-api *does not contain
any log adapters*.
> If so many people are having problems then this must be an error on
> Tomcat's behalf.
You are yet to demonstrate that there is a problem with Tomcat, or in
fact the Tomcat is unable to use Log4J. As I stated before, I am
successfully using JCL and Log4J on a number of servers - as I'm sure
other lists members are too.
> Also If I use the exact same lib files in the exact
> same place and the same configuration file but I replace
> protected final Log log = LogFactory.getLog( class ) (JCL)
> with
> protected final Logger logger = Logger.getLogger( class ) (Log4j)
>
> it should produce the same logging but it doesnt. When I use JCL no
> logging occures except to the system output but this is because tomcat
> uses java.util.Logging and that defaults output to the System.out
(see below)
> I hope someone can help out in getting JCL with tomcat and log4j to work.
I am trying to, but you're determined to stick to your faulty assumption
that there's a fault with Tomcat (which there doesn't appear to be to me).
I shall repeat my questions:
* have you set a logging level that will permit log messages to be
written to the file?
* what attributes are set in your application context configuration?
E.g. is the swallowOutput="true" attribute set?
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
Answer these, and we'll continue.
p
> Thanks in advance,
> Martyn
>
>
>
> Pid schreef:
>> Martyn Hiemstra wrote:
>>
>>> Hi All,
>>>
>>> I have been working with tomcat and log4j for a while and it worked
>>> perfectly. Now I have updated all my web apps to use commons logging. I
>>> have discovered that the Tomcat developers have absolutly no idea how to
>>> do something right when it comes to commons logging and I am curious to
>>> why.
>>>
>>
>> Non-specific insults are likely to generate attention, but unlikely to
>> encourage help. Never-the-less, I will attempt to assist.
>>
>>
>>> I tried tomcat 5.028 and commons logging. I discovered that tomcat used
>>> it's own commons-logging-api.jar file and it was impossible to override
>>> this commons logging file.
>>>
>>
>> commons-logging-api is not the same as commons-logging
>>
>>
>>> I am running tomcat 6 now and I have discovered that tomcat 6 uses
>>> commons logging without log4j enabled.
>>>
>>
>> log4j is 'enabled' when you configure it and supply the jar file.
>>
>>
>>> I have log4j.jar and commons-logging-1.1.jar in my webapp\WEB-INF\lib
>>> directory and I put my log4j.properties file in the
>>> webapp\WEB-INF\classes ditrectory so this should be correct.
>>
>> Sounds just like the configuration I am using, successfully I might add.
>>
>>
>>> If I create a FileAppender like this:
>>>
>>> log4j.appender.fileout=org.apache.log4j.RollingFileAppender
>>> log4j.appender.fileout.File=/tmp/myLog.log
>>> log4j.appender.fileout.MaxFileSize=1024KB
>>> log4j.appender.fileout.MaxBackupIndex=1
>>> log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
>>> log4j.appender.fileout.layout.conversionPattern=[%-6p] %-13d{ABSOLUTE}
>>> %-26C{1} %-4L %m%n
>>>
>>> I have discovered that the /tmp/myLog.log is created but nothing is
>>> outputed to this file.
>>>
>>
>> From the obvious questions department:
>>
>> * have you set a logging level that will permit log messages to be
>> written to the file?
>>
>> * what attributes are set in your application context configuration?
>>
>>
>>> I am curious, why have the tomcat developers disabled something that is
>>> so commonly used?
>>>
>>
>> It's not disabled, you are probably doing something wrong. Log4J works
>> perfectly well if it's configured correctly.
>>
>> p
>>
>>
>>
>>
>>> Thanks in advance,
>>> Martyn
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat Commons logging and log4j
Posted by Martyn Hiemstra <m....@minihouse.com>.
Hi Pid,
Thanks for your response. Please forgive my initial response. After
reading so much about how JCL isnt working correctly under Tomcat I was
getting frustrated. Having to spend 2 days getting it to work without
success is for every programmer frustrating.
I found this website: http://tomcat.apache.org/tomcat-6.0-doc/logging.html
It states that you need to activate it by building something first. This
means it isnt enabled be default.
I even found a website where a person stated that anybody using JCL with
tomcat are just plain stupid. Here is the link:
http://www.bileblog.org/?p=259
These blogs/forums also indicate problems with tomcat and JCL:
http://www.oreillynet.com/onjava/blog/2006/08/tomcat_5x_commons_logging_and.html
http://java2.5341.com/msg/96959.html
http://commons.apache.org/logging/commons-logging-1.1/troubleshooting.html#Apache_Tomcat
If so many people are having problems then this must be an error on
Tomcat's behalf. Also If I use the exact same lib files in the exact
same place and the same configuration file but I replace
protected final Log log = LogFactory.getLog( class ) (JCL)
with
protected final Logger logger = Logger.getLogger( class ) (Log4j)
it should produce the same logging but it doesnt. When I use JCL no
logging occures except to the system output but this is because tomcat
uses java.util.Logging and that defaults output to the System.out
I hope someone can help out in getting JCL with tomcat and log4j to work.
Thanks in advance,
Martyn
Pid schreef:
> Martyn Hiemstra wrote:
>
>> Hi All,
>>
>> I have been working with tomcat and log4j for a while and it worked
>> perfectly. Now I have updated all my web apps to use commons logging. I
>> have discovered that the Tomcat developers have absolutly no idea how to
>> do something right when it comes to commons logging and I am curious to
>> why.
>>
>
> Non-specific insults are likely to generate attention, but unlikely to
> encourage help. Never-the-less, I will attempt to assist.
>
>
>> I tried tomcat 5.028 and commons logging. I discovered that tomcat used
>> it's own commons-logging-api.jar file and it was impossible to override
>> this commons logging file.
>>
>
> commons-logging-api is not the same as commons-logging
>
>
>> I am running tomcat 6 now and I have discovered that tomcat 6 uses
>> commons logging without log4j enabled.
>>
>
> log4j is 'enabled' when you configure it and supply the jar file.
>
>
>> I have log4j.jar and commons-logging-1.1.jar in my webapp\WEB-INF\lib
>> directory and I put my log4j.properties file in the
>> webapp\WEB-INF\classes ditrectory so this should be correct.
>>
>
> Sounds just like the configuration I am using, successfully I might add.
>
>
>> If I create a FileAppender like this:
>>
>> log4j.appender.fileout=org.apache.log4j.RollingFileAppender
>> log4j.appender.fileout.File=/tmp/myLog.log
>> log4j.appender.fileout.MaxFileSize=1024KB
>> log4j.appender.fileout.MaxBackupIndex=1
>> log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
>> log4j.appender.fileout.layout.conversionPattern=[%-6p] %-13d{ABSOLUTE}
>> %-26C{1} %-4L %m%n
>>
>> I have discovered that the /tmp/myLog.log is created but nothing is
>> outputed to this file.
>>
>
> From the obvious questions department:
>
> * have you set a logging level that will permit log messages to be
> written to the file?
>
> * what attributes are set in your application context configuration?
>
>
>> I am curious, why have the tomcat developers disabled something that is
>> so commonly used?
>>
>
> It's not disabled, you are probably doing something wrong. Log4J works
> perfectly well if it's configured correctly.
>
> p
>
>
>
>
>> Thanks in advance,
>> Martyn
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat Commons logging and log4j
Posted by Pid <p...@pidster.com>.
Martyn Hiemstra wrote:
> Hi All,
>
> I have been working with tomcat and log4j for a while and it worked
> perfectly. Now I have updated all my web apps to use commons logging. I
> have discovered that the Tomcat developers have absolutly no idea how to
> do something right when it comes to commons logging and I am curious to
> why.
Non-specific insults are likely to generate attention, but unlikely to
encourage help. Never-the-less, I will attempt to assist.
> I tried tomcat 5.028 and commons logging. I discovered that tomcat used
> it's own commons-logging-api.jar file and it was impossible to override
> this commons logging file.
commons-logging-api is not the same as commons-logging
> I am running tomcat 6 now and I have discovered that tomcat 6 uses
> commons logging without log4j enabled.
log4j is 'enabled' when you configure it and supply the jar file.
> I have log4j.jar and commons-logging-1.1.jar in my webapp\WEB-INF\lib
> directory and I put my log4j.properties file in the
> webapp\WEB-INF\classes ditrectory so this should be correct.
Sounds just like the configuration I am using, successfully I might add.
> If I create a FileAppender like this:
>
> log4j.appender.fileout=org.apache.log4j.RollingFileAppender
> log4j.appender.fileout.File=/tmp/myLog.log
> log4j.appender.fileout.MaxFileSize=1024KB
> log4j.appender.fileout.MaxBackupIndex=1
> log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
> log4j.appender.fileout.layout.conversionPattern=[%-6p] %-13d{ABSOLUTE}
> %-26C{1} %-4L %m%n
>
> I have discovered that the /tmp/myLog.log is created but nothing is
> outputed to this file.
>From the obvious questions department:
* have you set a logging level that will permit log messages to be
written to the file?
* what attributes are set in your application context configuration?
> I am curious, why have the tomcat developers disabled something that is
> so commonly used?
It's not disabled, you are probably doing something wrong. Log4J works
perfectly well if it's configured correctly.
p
> Thanks in advance,
> Martyn
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org