I had actually hit the same snag in Log4J, i.e. multiple instances of the
same app. My solution was to create a "JavaHelper" native lib, which
allows me to get the process id. Then using that I enhanced the
DailyRollingFileAppender to support a %P in the filename for process id.
Renny Koshy
President & CEO
--------------------------------------------
RUBIX Information Technologies, Inc.
www.rubixinfotech.com
maarten
<maartenb@xxxxxx> To: Log4CXX User
<log4cxx-user@xxxxxxxxxxxxxxxxxx>
cc:
08/05/2005 03:37 Subject: [SPAM] Re: RE : File
Location Substitution.
AM
Please respond to
"Log4CXX User"
Problem is that it's a single-threaded process, for every user connecting
to the system a new process is spawned.
This means I have multiple instances of the same process running
simultaneously.
And I would like to have a log file per process.
I could send my loggings to Syslog but strangely enough the SysLogAppender
seems to be a lot slower than the FileAppender
and besides I wouldn't have a log file per process.
Note that I'm still using 0.9.7, but if the features I was asking for are
available in CVS HEAD I would consider upgrading.
Maarten
Alexandre Gacon wrote:
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@xxxxxx]
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
This document has been scanned by TrendMicro ScanMail (RIT Email Server)
|