RollingLogFileAppender and custom remote File

View: New views
3 Messages — Rating Filter:   Alert me  

RollingLogFileAppender and custom remote File

by Alvarez Alvarez, Victor Manuel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hello,

I have the next scenario, and I don’t know how to do it.

 

I need to use RollingLogFileAppender but the param name path file have to change in different environments. I would like the web.config file to be the same in 3 environments (TEST, PRE-PRODUCTION and PRODUCTION) and always write in the same remote server, but in different folder

 

<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">

      <param name="File" value="\\RemoteLogServer\TEST\app1\logs\currentlog.config"/>

      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

      <appendToFile value="true"/>

      <rollingStyle value="Date"/>

      <datePattern value="ddMMyyyy"/>

      <maxSizeRollBackups value="5"/>

      <maximumFileSize value="1MB"/>

      <filter type="log4net.Filter.LevelRangeFilter">

        <acceptOnMatch value="true"/>

        <levelMin value="DEBUG"/>

        <levelMax value="FATAL"/>

      </filter>

      <layout type="log4net.Layout.PatternLayout">

        <conversionPattern value="%-5p %d %5rms - %m%n"/>

      </layout>

    </appender>

 

In PRO will be

<param name="File" value="\\RemoteLogServer\PRO\app1\logs\currentlog.config"/>

 

 

¿How can I configure this line for not to change when I deploy it?, with any pattern or anything

For instance

<param name="File" value="\\RemoteLogServer\[%ENV%]\app1\logs\currentlog.config"/>

 

 

Best regards.

Victor.

 


RE: RollingLogFileAppender and custom remote File

by Alasdair Richardson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
The config will read environment variables in some places. I used this for a file name in an appender
 
 
  <appender name="file" type="log4net.Appender.FileAppender">
    <file value="${JCE_LOG_FILE}"/>
...
 
where JCE_LOG_FILE is an env var
 
Note thios doesnt seem to work everywhere since the follwoing did NOT work
 
 
  <root>
    <!-- Env var deosnt seem to work here, however the level will be overwritten in
         JcEnvironment to whatever was in the table -->
    <!--level value="${JCE_LOG_LEVEL}" /-->
    <level value="INFO" />
Hope that helps


From: Alvarez Alvarez, Victor Manuel [mailto:vmalvarez@...]
Sent: Thursday, September 10, 2009 3:02 PM
To: log4net-user@...
Subject: RollingLogFileAppender and custom remote File

Hello,

I have the next scenario, and I don’t know how to do it.

 

I need to use RollingLogFileAppender but the param name path file have to change in different environments. I would like the web.config file to be the same in 3 environments (TEST, PRE-PRODUCTION and PRODUCTION) and always write in the same remote server, but in different folder

 

<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">

      <param name="File" value="\\RemoteLogServer\TEST\app1\logs\currentlog.config"/>

      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

      <appendToFile value="true"/>

      <rollingStyle value="Date"/>

      <datePattern value="ddMMyyyy"/>

      <maxSizeRollBackups value="5"/>

      <maximumFileSize value="1MB"/>

      <filter type="log4net.Filter.LevelRangeFilter">

        <acceptOnMatch value="true"/>

        <levelMin value="DEBUG"/>

        <levelMax value="FATAL"/>

      </filter>

      <layout type="log4net.Layout.PatternLayout">

        <conversionPattern value="%-5p %d %5rms - %m%n"/>

      </layout>

    </appender>

 

In PRO will be

<param name="File" value="\\RemoteLogServer\PRO\app1\logs\currentlog.config"/>

 

 

¿How can I configure this line for not to change when I deploy it?, with any pattern or anything

For instance

<param name="File" value="\\RemoteLogServer\[%ENV%]\app1\logs\currentlog.config"/>

 

 

Best regards.

Victor.

 




____________________________________
The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

RE: RollingLogFileAppender and custom remote File

by Alvarez Alvarez, Victor Manuel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

The easiest way will be setting a URL (http://server/virtual_logs) path instead of a physical path. The virtual directory will be configured in the IIS with the correct path (\\RemoteServerLog\PRO\logs)

But, I don’t know how to do it, something like Server.Mappath that converts the path.

 

<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">

      <param name="File/sink/ ??? " value="%{Server.Mappath(‘http://server/virtual_logs’)"/>

     

 

Any idea??