Getting an error in logging while trying to use String interpolation (log4j) when setting log directory

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting an error in logging while trying to use String interpolation (log4j) when setting log directory

marcopas
When trying to set a log directory inside Config.groovy using String interpolation i get an error:

| Error log4j:ERROR Property missing when configuring log4j: logDirectory

But when I use the log directory directly it all seems to work fine.

This gives an error:
log4j = {
    logDirectory    = "/tmp"

    appenders {
        file    name:'prodfile', file: "${logDirectory}/production.log"
}

and this works:
l
og4j = {
    appenders {
        file    name:'prodfile', file: "/tmp/production.log"
}

Any clue what i am missing here?
Running Grails 2.3.5 by the way..

--
Marco Pas
Reply | Threaded
Open this post in threaded view
|

Re: Getting an error in logging while trying to use String interpolation (log4j) when setting log directory

Tobias Kraft
Can you try to define the variable outside of the log4j block?

Something like this: 

def logLocation = '/opt/share/tomcat/log/'

log4j = {
    appenders {
        rollingFile name: "appRollingFile",  maxFileSize: "10MB", 'append': true, file: "${logLocation}portal.log"
        ....
    }
....


2014-02-14 8:37 GMT+01:00 Marco Pas <[hidden email]>:
When trying to set a log directory inside Config.groovy using String interpolation i get an error:

| Error log4j:ERROR Property missing when configuring log4j: logDirectory

But when I use the log directory directly it all seems to work fine.

This gives an error:
log4j = {
    logDirectory    = "/tmp"

    appenders {
        file    name:'prodfile', file: "${logDirectory}/production.log"
}

and this works:
l
og4j = {
    appenders {
        file    name:'prodfile', file: "/tmp/production.log"
}

Any clue what i am missing here?
Running Grails 2.3.5 by the way..

--
Marco Pas