You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by DECAFFMEYER MATHIEU <MA...@fortis.lu> on 2007/01/05 10:22:36 UTC

Commons Logging - FileAppender Issue

Hi,

I'm using Log4j to manage log, I want to convert this by Commons Logging
by
converting just this line :
private static Logger sLogger = Logger.getLogger(LoggingManager.class);
by this one :
private static Log sLogger = LogFactory.getLog(LoggingManager.class);
This is the only thing to do, right ?
Now I have a problem : logs aren't stored in files anymore.
Why doesn't it store anymore since I replaced this line to use Commons
Logging ?

Thank u for any help.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
     <appender name="fileAppender" 
               class="org.apache.log4j.DailyRollingFileAppender">
          <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
          <param name="File" value="C:/UserTemp/matthew016/app.log"/>
          <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern" 
                      value="%d{ISO8601} %-5p [%-30.30c{2}] %m%n"/>
          </layout>
     </appender>
     <appender name="consoleAppender" 
               class="org.apache.log4j.ConsoleAppender">
          <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern" 
                      value="%-5p %c{1} - %m%n" />
          </layout>
     </appender>
  <root>
    <priority value ="info" />
    <appender-ref ref="fileAppender" />
    <appender-ref ref="consoleAppender" />
  </root>
</log4j:configuration>

__________________________________




============================================
Internet communications are not secure and therefore Fortis Banque Luxembourg S.A. does not accept legal responsibility for the contents of this message. The information contained in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Nothing in the message is capable or intended to create any legally binding obligations on either party and it is not intended to provide legal advice.
============================================


Re: Commons Logging - FileAppender Issue

Posted by Dennis Lundberg <de...@apache.org>.
Hi

Do you have a configuration file for log4j in your classpath?

What you have done is switched from hardwired log4j to exchangeable 
log4j. This means that the user of your product can select which logging 
implementation they want to use. In your case you want to use log4j. 
With this new setup you still need the configuration file for log4j, 
i.e. log4j.properties or log4j.xml.

DECAFFMEYER MATHIEU wrote:
>  Thank u.
> I can see log4j is used by default and that commons try to find it in
> the classpath. So I don't actually need to put anything in commons- 
> logging.properties. Anyway I tried to make commons- 
> logging.properties and add
> org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogg
> er
> But it still has no effect
> 
> 
> __________________________________
> 
> 
> 
>     
> 
> -----Original Message-----
> From: Torsten Curdt [mailto:tcurdt@apache.org] 
> Sent: Friday, January 05, 2007 10:32 AM
> To: Jakarta Commons Users List
> Subject: Re: Commons Logging - FileAppender Issue
> 
> *****  This message comes from the Internet Network *****
> 
>> I'm using Log4j to manage log, I want to convert this by Commons  
>> Logging by
>> converting just this line :
>> private static Logger sLogger = Logger.getLogger 
>> (LoggingManager.class);
>> by this one :
>> private static Log sLogger = LogFactory.getLog(LoggingManager.class);
> 
> Regarding the static give this a read
> 
> http://wiki.apache.org/jakarta-commons/Logging/StaticLog
>> This is the only thing to do, right ?
>> Now I have a problem : logs aren't stored in files anymore.
>> Why doesn't it store anymore since I replaced this line to use  
>> Commons Logging ?
> Because you need to configure commons logging to use whatever  
> implementation you want ...assume log4j. See the docs. commons- 
> logging.properties might be what you are after.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 
> 
> ============================================
> Internet communications are not secure and therefore Fortis Banque Luxembourg S.A. does not accept legal responsibility for the contents of this message. The information contained in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Nothing in the message is capable or intended to create any legally binding obligations on either party and it is not intended to provide legal advice.
> ============================================
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
Dennis Lundberg

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


Re: Commons Logging - FileAppender Issue

Posted by Thorbjørn Ravn Andersen <th...@gmail.com>.
DECAFFMEYER MATHIEU skrev  den 05-01-2007 12:06:
>  Thank u.
> I can see log4j is used by default and that commons try to find it in
> the classpath. So I don't actually need to put anything in commons- 
> logging.properties. Anyway I tried to make commons- 
> logging.properties and add
> org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogg
> er
> But it still has no effect
>   
There are some classloader wrinkles with commons logging 1.0.4 which I 
decided to circumvent by stripping down this code to just selecting log4j.

I'd be happy to share if you need it - it is just 6 classes in an 
eclipse project.

-- 
  Thorbjørn

RE: Commons Logging - FileAppender Issue

Posted by DECAFFMEYER MATHIEU <MA...@fortis.lu>.
 Thank u.
I can see log4j is used by default and that commons try to find it in
the classpath. So I don't actually need to put anything in commons- 
logging.properties. Anyway I tried to make commons- 
logging.properties and add
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogg
er
But it still has no effect


__________________________________



    

-----Original Message-----
From: Torsten Curdt [mailto:tcurdt@apache.org] 
Sent: Friday, January 05, 2007 10:32 AM
To: Jakarta Commons Users List
Subject: Re: Commons Logging - FileAppender Issue

*****  This message comes from the Internet Network *****

> I'm using Log4j to manage log, I want to convert this by Commons  
> Logging by
> converting just this line :
> private static Logger sLogger = Logger.getLogger 
> (LoggingManager.class);
> by this one :
> private static Log sLogger = LogFactory.getLog(LoggingManager.class);

Regarding the static give this a read

http://wiki.apache.org/jakarta-commons/Logging/StaticLog
> This is the only thing to do, right ?
> Now I have a problem : logs aren't stored in files anymore.
> Why doesn't it store anymore since I replaced this line to use  
> Commons Logging ?
Because you need to configure commons logging to use whatever  
implementation you want ...assume log4j. See the docs. commons- 
logging.properties might be what you are after.



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



============================================
Internet communications are not secure and therefore Fortis Banque Luxembourg S.A. does not accept legal responsibility for the contents of this message. The information contained in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Nothing in the message is capable or intended to create any legally binding obligations on either party and it is not intended to provide legal advice.
============================================


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


Re: Commons Logging - FileAppender Issue

Posted by Torsten Curdt <tc...@apache.org>.
> I'm using Log4j to manage log, I want to convert this by Commons  
> Logging by
> converting just this line :
> private static Logger sLogger = Logger.getLogger 
> (LoggingManager.class);
> by this one :
> private static Log sLogger = LogFactory.getLog(LoggingManager.class);

Regarding the static give this a read

http://wiki.apache.org/jakarta-commons/Logging/StaticLog
> This is the only thing to do, right ?
> Now I have a problem : logs aren't stored in files anymore.
> Why doesn't it store anymore since I replaced this line to use  
> Commons Logging ?
Because you need to configure commons logging to use whatever  
implementation you want ...assume log4j. See the docs. commons- 
logging.properties might be what you are after.



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


Re: Commons Logging - FileAppender Issue

Posted by Simon Kitching <sk...@apache.org>.
On Fri, 2007-01-05 at 10:22 +0100, DECAFFMEYER MATHIEU wrote:
> 
> Hi,
> 
> I'm using Log4j to manage log, I want to convert this by Commons
> Logging by 
> converting just this line : 
> private static Logger sLogger =
> Logger.getLogger(LoggingManager.class); 
> by this one : 
> private static Log sLogger = LogFactory.getLog(LoggingManager.class); 
> This is the only thing to do, right ? 

Yep, those are all the code changes you need, and in most cases there
are no config file changes needed either.

The only case where you may need to do more are where the code is
running inside a j2ee container or similar, and there are multiple
copies of various logging libraries floating around.

> Now I have a problem : logs aren't stored in files anymore. 
> Why doesn't it store anymore since I replaced this line to use Commons
> Logging ?

At a guess, there are multiple copies of log4j in your classpath, and
commons-logging is finding one that does not have access to your log4j
configuration file.

Enable commons-logging diagnostic output and see what log4j jarfile is
being detected by commons-logging.

Regards,

Simon


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