Ian, you should try something like this in your config file,
log4j.appender.fileapndr.filename = \
sub {File::Basename::basename($0)."log"}
log4j.appender.fileapndr = Log::Dispatch::File
log4j.appender.fileapndr.layout=org.apache.log4j.SimpleLayout
(requires a 'use File::Basename' somewhere in your code)
Mike Schilli wrote:
> Subject: Sorry for mailing you directly
> Date: 8/20/2003, 3:28 PM
> From: Ian harisay <ia...@gr...>
> To: log...@pe...
>
> Hi Mike,
>
> First of all, I love all the work that has been done on Log4perl.
>
> I am hoping you can help me out. I am trying to set up a package that I
> can call in my main program. The package is as such:
>
> package Log::Init;
>
> require 5.005;
> use strict;
> use Log::Log4perl;
> use vars qw($VERSION);
>
> $VERSION = 0.01;
>
> Log::Log4perl->init("/opt/perl/lib/log.conf");
>
> ### end of module ###
>
> Then my main program can just be written as such:
>
> use Log::Init;
>
> my $log = Log::Log4perl->get_logger();
>
> $log->info('my log message');
>
> This is working fine for me when I initialise from a conf file. The
> problem I am having, however, is that I would like my log file name to
> be dynamically generated. For instance when my program (myprog) is
> calls Log::Init, Log::Init will setup a log file called myprog.log.
> This is default behaviour I am after. I have tried to do this, but have
> not been successful. Could you help me out with this?
>
> Also, I looked for a log4perl users mail list. Didn't find one. I
> found the log4perl-devel list, but am having trouble posting to it. I
> only say this because I don't want you to think I haven't exhausted
> these avenues first.
>
> Thanks,
>
> Ian
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by Dice.com.
> Did you know that Dice has over 25,000 tech jobs available today? From
> careers in IT to Engineering to Tech Sales, Dice has tech jobs from the
> best hiring companies. http://www.dice.com/index.epl?rel_code=104
> _______________________________________________
> log4perl-devel mailing list
> log...@li...
> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
--
Happy Trails . . .
Kevin M. Goess
(and Anne and Frank)
904 Carmel Ave.
Albany, CA 94706
(510) 525-5217
|