Quantcast

Logging into separate file

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Logging into separate file

barvinsky
Hi All,
 
can anyone help me to figure out how to log into a separate file from my application under Tomcat ?
 
I put following lines into my Config.groovy:
 
    appender.bdb_admin = "org.apache.log4j.FileAppender"
    appender.'bdb_admin.layout'="org.apache.log4j.PatternLayout"
    appender.'bdb_admin.layout.ConversionPattern'='%d{yyyy-MM-dd HH:mm:ss.SSS} %c{2} %m%n'
    appender.'bdb_admin.File'="bdb_admin.log"
then I add it to the root logger:
 
    rootLogger="info, stdout, bdb_admin"
but no file is created in tomcat log folder. I would not like to use absolute path there since this app is hosted on multiple servers with different setups.
 
Does anyone have any idea on how to achieve that and why the file is not created?
Thanks,
Andrew.
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Logging into separate file

Jason Morris-5
Have you looked in the tomcat startup directory (i.e. wherever you run startup.bat/.sh) rather than the logs dir? Log4j just puts the file wherever you are running, it has no implied knowledge of the tomcat logs dir.

Your config looks okay (as long as you added bdb_admin to the rootLogger), so my guess is the file is just going to a different directory.

Jason

On Mon, Sep 29, 2008 at 11:28 PM, Andrew Barvinsky (abarvins) <[hidden email]> wrote:
Hi All,
 
can anyone help me to figure out how to log into a separate file from my application under Tomcat ?
 
I put following lines into my Config.groovy:
 
    appender.bdb_admin = "org.apache.log4j.FileAppender"
    appender.'bdb_admin.layout'="org.apache.log4j.PatternLayout"
    appender.'bdb_admin.layout.ConversionPattern'='%d{yyyy-MM-dd HH:mm:ss.SSS} %c{2} %m%n'
    appender.'bdb_admin.File'="bdb_admin.log"
then I add it to the root logger:
 
    rootLogger="info, stdout, bdb_admin"
but no file is created in tomcat log folder. I would not like to use absolute path there since this app is hosted on multiple servers with different setups.
 
Does anyone have any idea on how to achieve that and why the file is not created?
Thanks,
Andrew.
 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Logging into separate file

barvinsky
Yes Jason it is there, so I guess I asked wrong question.
 
The question becomes - how can I reference log folder in Grails Config.groovy file?
 
something like ${CATALINA_HOME}/logs/
 
but I tried CATALINA_HOME and it does not work
 
=============
 
Have you looked in the tomcat startup directory (i.e. wherever you run startup.bat/.sh) rather than the logs dir? Log4j just puts the file wherever you are running, it has no implied knowledge of the tomcat logs dir.

Your config looks okay (as long as you added bdb_admin to the rootLogger), so my guess is the file is just going to a different directory.

Jason

On Mon, Sep 29, 2008 at 11:28 PM, Andrew Barvinsky (abarvins) <[hidden email]> wrote:
Hi All,
 
can anyone help me to figure out how to log into a separate file from my application under Tomcat ?
 
I put following lines into my Config.groovy:
 
    appender.bdb_admin = "org.apache.log4j.FileAppender"
    appender.'bdb_admin.layout'="org.apache.log4j.PatternLayout"
    appender.'bdb_admin.layout.ConversionPattern'='%d{yyyy-MM-dd HH:mm:ss.SSS} %c{2} %m%n'
    appender.'bdb_admin.File'="bdb_admin.log"
then I add it to the root logger:
 
    rootLogger="info, stdout, bdb_admin"
but no file is created in tomcat log folder. I would not like to use absolute path there since this app is hosted on multiple servers with different setups.
 
Does anyone have any idea on how to achieve that and why the file is not created?
Thanks,
Andrew.
 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Logging into separate file

Brad Whitaker
Are you trying to get the catalina home as you described it, or are you trying it like this (which should work):

def catBaseDir = System.properties.getProperty('catalina.base') // null except when running in Tomcat

(I think you're better off using 'catalina.base' than 'catalina.home'. There are advantages to using separate directories for 'base' and 'home', and the 'logs' directory is associated with 'base' rather than 'home'.)


barvinsky wrote
Yes Jason it is there, so I guess I asked wrong question.
 
The question becomes - how can I reference log folder in Grails
Config.groovy file?
 
something like ${CATALINA_HOME}/logs/
 
but I tried CATALINA_HOME and it does not work
 
=============

 
Have you looked in the tomcat startup directory (i.e. wherever you run
startup.bat/.sh) rather than the logs dir? Log4j just puts the file
wherever you are running, it has no implied knowledge of the tomcat logs
dir.

Your config looks okay (as long as you added bdb_admin to the
rootLogger), so my guess is the file is just going to a different
directory.

Jason


On Mon, Sep 29, 2008 at 11:28 PM, Andrew Barvinsky (abarvins)
<abarvins@cisco.com> wrote:


        Hi All,
         
        can anyone help me to figure out how to log into a separate file
from my application under Tomcat ?
         
        I put following lines into my Config.groovy:
         
            appender.bdb_admin = "org.apache.log4j.FileAppender"
            appender.'bdb_admin.layout'="org.apache.log4j.PatternLayout"
            appender.'bdb_admin.layout.ConversionPattern'='%d{yyyy-MM-dd
HH:mm:ss.SSS} %c{2} %m%n'
            appender.'bdb_admin.File'="bdb_admin.log"
       
        then I add it to the root logger:
         
            rootLogger="info, stdout, bdb_admin"
       
        but no file is created in tomcat log folder. I would not like to
use absolute path there since this app is hosted on multiple servers
with different setups.
         
        Does anyone have any idea on how to achieve that and why the
file is not created?
        Thanks,
        Andrew.
         

Loading...