You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by "Vanderkolk, John" <Jo...@compuware.com> on 2007/07/25 13:42:59 UTC

File Paths

Hello,

I'm writing a logger utility for a solution that has several different
points of execution. They will all be under some particular folder, but
relative to this folder their locations are different. All of these
applications are to read the same config file which specifies locations
for file appenders, one for each of the points of execution.

My problem is that since log4net reads the paths specified in the config
file as relative to the executing module, when each executable is run,
it makes log files in different locations when I want them all to make
log files in the same location.

EX: Here is an example with 2 executables:

...\Installation Folder\
	log.config
	Program 1\
		Sln1.exe
	Program2\
		Bin\
			Sln2.exe
	Logs\
		Log1.txt
		Log2.txt

The problem is that since both exe's read the same config file, I can't
get them both to write logs to the same place. Short of writing my own
utility to configure the loggers I don't see any other way.


Any help would be appreciated,
John VanderKolk
john.vanderkolk@compuware.com
The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.

RE: File Paths

Posted by "Vanderkolk, John" <Jo...@compuware.com>.
My problem is slightly different. I'm not having a problem with the File
Appenders being able to open and write to their files. If all of the
exe's run from the same location they open their logs and log fine.
Since they all use the same log.config file however, if the exe's run
from different locations they create different log files and I don't
want this. I want to be able to have exe's in different locations load
the same config file (which I've accomplished via code) and have them
place logs in the same path without specifying it as an absolute path
inside of the config file.

 

John VanderKolk 

From: Michael Schall [mailto:mike.schall@gmail.com] 
Sent: Wednesday, July 25, 2007 10:04 AM
To: Log4NET User
Subject: Re: File Paths

 

I had a similar problem where the same exe could be launched multiple
times at the same time.  You can modify the filename of the log by
properties in log4net.  I used the processid there may be something like
assemblyName or something... 

    <appender name="RollingFile"
type="log4net.Appender.RollingFileAppender">
        <file type="log4net.Util.PatternString"
value="log\foo-pid%processid-" /> 
        <rollingStyle value="Composite" />
        <appendToFile value="false" />
        <datePattern value="yyyyMMdd" />
        <maximumFileSize value="100MB" /> 
        <maxSizeRollBackups value="-1" />
        <StaticLogFileName value="false" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%5level [%date] [%thread] %-
30.30logger{2}    %message%newline" />
        </layout>
    </appender>

On 7/25/07, Vanderkolk, John < John.Vanderkolk@compuware.com
<ma...@compuware.com> > wrote:

Hello,

I'm writing a logger utility for a solution that has several different
points of execution. They will all be under some particular folder, but
relative to this folder their locations are different. All of these
applications are to read the same config file which specifies locations
for file appenders, one for each of the points of execution.

My problem is that since log4net reads the paths specified in the config
file as relative to the executing module, when each executable is run ,
it makes log files in different locations when I want them all to make
log files in the same location.

EX: Here is an example with 2 executables:

...\Installation Folder\

        log.config

        Progr am 1\

                Sln1.exe

        Program2\

                Bin\

                        Sln2.exe

        Logs\

                Log1.txt

                Log2.txt

The problem is that since both exe's read the same config file, I can' t
get them both to write logs to the same place. Short of writing my own
utility to configure the loggers I don 't see any other way.

Any help would be appreciated,

John VanderKolk 

john.vanderkolk@compuware.com


The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it,
or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it .

 


Re: File Paths

Posted by Michael Schall <mi...@gmail.com>.
I had a similar problem where the same exe could be launched multiple times
at the same time.  You can modify the filename of the log by properties in
log4net.  I used the processid there may be something like assemblyName or
something...

    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender
">
        <file type="log4net.Util.PatternString"
value="log\foo-pid%processid-" />
        <rollingStyle value="Composite" />
        <appendToFile value="false" />
        <datePattern value="yyyyMMdd" />
        <maximumFileSize value="100MB" />
        <maxSizeRollBackups value="-1" />
        <StaticLogFileName value="false" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%5level [%date] [%thread] %-
30.30logger{2}    %message%newline" />
        </layout>
    </appender>

On 7/25/07, Vanderkolk, John <Jo...@compuware.com> wrote:
>
>  Hello,
>
> I'm writing a logger utility for a solution that has several different
> points of execution. They will all be under some particular folder, but relative
> to this folder their locations are different. All of these applications
> are to read the same config file which specifies locations for file
> appenders, one for each of the points of execution.
>
> My problem is that since log4net reads the paths specified in the config file
> as relative to the executing module, when each executable is run, it makeslog files in different locations when I want them
> all to make log files in the same location.
>
> EX: Here is an example with 2 executables:
>
> …\Installation Folder\
>
>         log.config
>
>         Program 1\
>
>                 Sln1.exe
>
>         Program2\
>
>                 Bin\
>
>                         Sln2.exe
>
>         Logs\
>
>                 Log1.txt
>
>                 Log2.txt
>
> The problem is that since both exe's read the same config file, I can't
> get them both to write logs to the same place. Short of writing my own
> utility to configure the loggers I don't see any other way.
>
> Any help would be appreciated,
>
> John VanderKolk
>
> john.vanderkolk@compuware.com
>
>  The contents of this e-mail are intended for the named addressee only. It
> contains information that may be confidential. Unless you are the named
> addressee or an authorized designee, you may not copy or use it, or disclose
> it to anyone else. If you received it in error please notify us immediately
> and then destroy it.
>
>