You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Alexandre Gacon <al...@masagroup.net> on 2005/08/05 09:20:18 UTC

RE : File Location Substitution.

Instead of calling the file with the pid in the name, couldn't you use a
unique rolling file and output the thread id in the result, using a pattern
appender for example ?

Alexandre

-----Message d'origine-----
De : maarten [mailto:maartenb@dns.be] 
Envoyé : vendredi 5 août 2005 09:17
À : Log4CXX User
Objet : Re: File Location Substitution.


Are there any other properties that I can use as placeholders in my 
log4cxx.properties file.
Can I use environment variables, that will be expanded at runtime ? What
about the process id ?

What I do now is define a RollingFile appender in my properties file and 
do my own hard-coded initialization :

  Appender* appender = Logger::getRootLogger()->getAppender ("RollingFile");
  FileAppender* fa = dynamic_cast<FileAppender*>(appender);
  if (fa != 0) {
     string fullpath = "/var/log/example_" + getEnvVar("REMOTE_IP") + 
"_" + getDatetime() + "_" + getPID() + ".log";
     fa->setFile ( fullpath );
     fa->activateOptions();
  }

Thanks,
Maarten

Curt Arnold wrote:

>
>
> On Aug 4, 2005, at 10:55 PM, macdev wrote:
>
>> I know I can set the location of the logfile used by Log4CXX using
>> the config files. I do this in the snippet I have included below.  
>> But how do I tailor the location at runtime? For example on a unix  
>> system how can make sure the logs go to a specific folder beneath  
>> the users home folder.
>>
>> logdir=/Users/devguy/library/Application Support/logs
>>
>> log4j.appender.PriParser=org.apache.log4j.FileAppender
>> log4j.appender.PriParser.File=${logdir}/parser_internal.log
>>
>> Thanks.
>> p.s. I bought the manual hoping it would help me, but what I am
>> looking for eludes me.
>
>
> log4cxx mimics the user.home, user.name, user.dir, java.io.tmpdir  
> properties that work with log4j.  So you could do:
>
>> log4j.appender.PriParser.File=${user.home}/parser_internal.log
>
>
>
>
>