Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Log4net does not works in production env
Prev Next
You are not authorized to post a reply.

Author Messages
S. K Rahman

12/23/2005 3:40 PM  

Hello all,

I am facing a strange problem.
The problem seems exactly like somebody posted earlier

-------------
Logging is working fine on my dev machine but when I deploy it does
not do anything. I copied  the whole code on the production machine
and tried debugging it, it worked fine, I go the logs.
---------
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4net-user@logging.apache.org&msgId=1605998

I have enabled the log4net debug but it does not seems to work as
well. So I tried building log4net again in the production server and
used the binaries from build, but it does not work either.

I am not sure how can I debug the problem. I tought that problem to be
permission related but it's not the case also if I use process
explorer from systeinternals.com I can see the log4net dll loaded by
w3wp.exe where as in my development machine it is  aspnet_wp.exe
My development machine is XP where as production is Windows 2003.

I am trying to d log.debug("my message") from the asp.net code.

Here is the my log4net config and web.config

---------
<?xml version="1.0" encoding="utf-8" ?>
<log4net debug="true">
        <appender name="LogFileAppender" type="log4net.Appender.FileAppender" >
                <file value="mylog.Log" />
                <appendToFile value="true" />
                <layout type="log4net.Layout.PatternLayout">
                        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] -
%message%newline" />
                </layout>
        </appender>
        <appender name="HttpTraceAppender"
type="log4net.Appender.AspNetTraceAppender" >
                <layout type="log4net.Layout.PatternLayout">
                        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] -
%message%newline" />
                </layout>
        </appender>
        <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
                <to value="myemailid@mydomain.com" />
                <from value="myemailid@mydomain.com" />
                <subject value="Logger message" />
                <smtpHost value="plex" />
                <bufferSize value="512" />
                <lossy value="true" />
                <evaluator type="log4net.Core.LevelEvaluator">
                        <threshold value="DEBUG"/>
                </evaluator>
                <layout type="log4net.Layout.PatternLayout">
                        <conversionPattern value="%newline%date [%thread] %-5level %logger
[%property{NDC}] - %message%newline%newline%newline" />
                </layout>
        </appender>
        <appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
                <file value="CustomLogs\CustomLogs.log" />
                <appendToFile value="true" />
                <datePattern value="yyyyMMdd" />
                <rollingStyle value="Date" />
                <maxSizeRollBackups value="10" />
                <maximumFileSize value="5MB" />
                <rollingStyle value="Size" />
                <staticLogFileName value="true" />
                <layout type="log4net.Layout.PatternLayout">
                        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] -
%message%newline" />
                </layout>
        </appender>
        <root>
                <level value="DEBUG" />
                <appender-ref ref="LogFileAppender" />
                <appender-ref ref="HttpTraceAppender" />
                <appender-ref ref="SmtpAppender" />
                <!-- <appender-ref ref="RollingLogFileAppender" /> -->
                <appender-ref ref="RollingLogFileAppender" />
        </root>
</log4net>
-----------------

-------------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>

    <!--  DYNAMIC DEBUG COMPILATION
          Set compilation debug="true" to enable ASPX debugging.
Otherwise, setting this value to
          false will improve runtime performance of this application.
          Set compilation debug="true" to insert debugging symbols
(.pdb information)
          into the compiled page. Because this creates a larger file
that executes
          more slowly, you should set this value to true only when
debugging and to
          false at all other times. For more information, refer to the
documentation about
          debugging ASP.NET files.
    -->
    <compilation
         defaultLanguage="c#"
         debug="true"
    />

    <!--  CUSTOM ERROR MESSAGES
          Set customErrors mode="On" or "RemoteOnly" to enable custom
error messages, "Off" to disable.
          Add <error> tags for each of the errors you want to handle.

          "On" Always display custom (friendly) messages.
          "Off" Always display detailed ASP.NET error information.
          "RemoteOnly" Display custom (friendly) messages only to
users not running
           on the local Web server. This setting is recommended for
security purposes, so
           that you do not display application detail information to
remote clients.
    -->

   <customErrors mode="RemoteOnly"/>
   <!--
      <error statusCode="500" redirect="/err500.aspx"/>
      <error statusCode="404" redirect="/err04.aspx"/>
      <error statusCode="403" redirect="/err403.aspx"/>
      </customErrors>
    -->


    <!--  AUTHENTICATION
          This section sets the authentication policies of the
application. Possible modes are "Windows",
          "Forms", "Passport" and "None"

          "None" No authentication is performed.
          "Windows" IIS performs authentication (Basic, Digest, or
Integrated Windows) according to
           its settings for the application. Anonymous access must be
disabled in IIS.
          "Forms" You provide a custom form (Web page) for users to
enter their credentials, and then
           you authenticate them in your application. A user
credential token is stored in a cookie.
          "Passport" Authentication is performed via a centralized
authentication service provided
           by Microsoft that offers a single logon and core profile
services for member sites.
    -->
    <authentication mode="Windows" />

        <!--  AUTHORIZATION
          This section sets the authorization policies of the
application. You can allow or deny access
          to application resources by user or role. Wildcards: "*"
mean everyone, "?" means anonymous
          (unauthenticated) users.
    -->

    <authorization>
        <allow users="*" /> <!-- Allow all users -->
            <!--  <allow     users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
                  <deny      users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
            -->
    </authorization>

    <!--  APPLICATION-LEVEL TRACE LOGGING
          Application-level tracing enables trace log output for every
page within an application.
          Set trace enabled="true" to enable application trace
logging.  If pageOutput="true", the
          trace information will be displayed at the bottom of each
page.  Otherwise, you can view the
          application trace log by browsing the "trace.axd" page from
your web application
          root.
    -->
    <trace
        enabled="true"
        requestLimit="50"
        pageOutput="false"
        traceMode="SortByTime"
                localOnly="false"
    />

    <!--  SESSION STATE SETTINGS
          By default ASP.NET uses cookies to identify which requests
belong to a particular session.
          If cookies are not available, a session can be tracked by
adding a session identifier to the URL.
          To disable cookies, set sessionState cookieless="true".
    -->
    <sessionState
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
            cookieless="false"
            timeout="20"
    />

    <!--  GLOBALIZATION
          This section sets the globalization settings of the application.
    -->
    <globalization
            requestEncoding="utf-8"
            responseEncoding="utf-8"
   />

 </system.web>

</configuration>
----------

Nicko Cadell

12/23/2005 3:48 PM  

Do you get any output if you enable internal log4net debug and use the
sysinternals debugview?
http://logging.apache.org/log4net/release/faq.html#internalDebug

Cheers,
Nicko

S. K Rahman

12/23/2005 4:01 PM  

On 12/23/05, Nicko Cadell <nicko@neoworks.com> wrote:
> Do you get any output if you enable internal log4net debug and use the
> sysinternals debugview?
> http://logging.apache.org/log4net/release/faq.html#internalDebug
>

I did enabled debugging  but I was not sure how view. I downloaded
debugview and indeed I got the output.
As for the log it seems to be issue with the permission but I have
given aspnet account/ IUSR account and other accounts full rights to
that app folder as well as the log file.

Here is the text

󞸼] log4net: FileAppender: Opening file for writing
[E:\www\l4n\mylog.Log] append [True]
󞸼] log4net:ERROR [FileAppender] Unable to acquire lock on file
E:\www\l4n\mylog.Log. Access to the path "E:\www\l4n\mylog.Log" is
denied.
󞸼] log4net:ERROR [FileAppender]
OpenFile(E:\www\l4n\mylog.Log,True) call failed.
󞸼] LockStateException: The file is not currently locked
󞸼]    at log4net.Appender.LockingStream.AssertLocked()
󞸼]    at log4net.Appender.LockingStream.get_CanWrite()
󞸼]    at System.IO.StreamWriter..ctor(Stream stream, Encoding
encoding, Int32 bufferSize)
󞸼]    at System.IO.StreamWriter..ctor(Stream stream, Encoding encoding)
󞸼]    at log4net.Appender.FileAppender.OpenFile(String fileName,
Boolean append)
󞸼]    at log4net.Appender.FileAppender.SafeOpenFile(String
fileName, Boolean append)
󞸼] log4net:ERROR [FileAppender] No output stream or file set for
the appender named [LogFileAppender].
󞸼] log4net:ERROR [SmtpAppender] Error occurred while sending
e-mail notification.
󞸼] System.Web.HttpException: Could not access 'CDO.Message'
object. ---> System.Reflection.TargetInvocationException: Exception
has been thrown by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x8004020F): The server
rejected one or more recipient addresses. The server response was: 550
5.7.1 Unable to relay myemailid@mydomain.com
󞸼]
󞸼]    --- End of inner exception stack trace ---
󞸼]    at System.RuntimeType.InvokeDispMethod(String name,
BindingFlags invokeAttr, Object target, Object[] args, Boolean[]
byrefModifiers, Int32 culture, String[] namedParameters)
󞸼]    at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
󞸼]    at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object
obj, String methodName, Object[] args)
󞸼]    --- End of inner exception stack trace ---
󞸼]    at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object
obj, String methodName, Object[] args)
󞸼]    at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
󞸼]    at System.Web.Mail.SmtpMail.Send(MailMessage message)
󞸼]    at log4net.Appender.SmtpAppender.SendBuffer(LoggingEvent[] events)
󞸼] log4net: FileAppender: Opening file for writing
[E:\www\l4n\Logs\mylog.Log] append [True]
󞸼] log4net:ERROR [RollingFileAppender] Unable to acquire lock on
file E:\www\l4n\Logs\mylog.Log. Access to the path
"E:\plexwww\l4n\PMSLogs\PMSlog.log" is denied.
󞸼] log4net:ERROR [RollingFileAppender]
OpenFile(E:\www\l4n\Logs\mylog.Log,True) call failed.
󞸼] LockStateException: The file is not currently locked
󞸼]    at log4net.Appender.LockingStream.AssertLocked()
󞸼]    at log4net.Appender.LockingStream.get_CanWrite()
󞸼]    at System.IO.StreamWriter..ctor(Stream stream, Encoding
encoding, Int32 bufferSize)
󞸼]    at System.IO.StreamWriter..ctor(Stream stream, Encoding encoding)
󞸼]    at log4net.Appender.FileAppender.OpenFile(String fileName,
Boolean append)
󞸼]    at log4net.Appender.RollingFileAppender.OpenFile(String
fileName, Boolean append)
󞸼]    at log4net.Appender.FileAppender.SafeOpenFile(String
fileName, Boolean append)
󞸼] log4net:ERROR [RollingFileAppender] No output stream or file
set for the appender named [RollingLogFileAppender].
𖓸] EVENT="heartbeat";INTERVAL=30;MN_KEY_SEQ=<ctrl+alt+f1>;
𖓸] EVENT="update";MACADDR=:00:0d:56:bb:88:15;CRYPT=:0e:87:ef:29:e8:c6:10:82;
󞟜] ASPI Polling Devices
󞟜] ASPIPro PollBus
󞟜] ASPIPro PollBus

Nicko Cadell

12/23/2005 4:03 PM  

What is the identity for the IIS6 Application Pool for your site? Have
you given this identity the correct permissions? By default it is the
Network Service account.

Nicko

S. K Rahman

12/23/2005 4:23 PM  

On 12/23/05, Nicko Cadell <nicko@neoworks.com> wrote:
> What is the identity for the IIS6 Application Pool for your site? Have
> you given this identity the correct permissions? By default it is the
> Network Service account.
>

Hey it worked.... The network service account did have full control.
Thanks for the help. :)

The funny part is due to the same reason smtpAppender also did not worked.
Thank you again.

Regards

S. K Rahman

12/26/2005 2:28 PM  

Hi,

I am back again now with the same problem...
This time I am not even getting output in DebugView.
I have enabled <add key="log4net.Internal.Debug" value="true"/> in web.config

But neither there is any debug output neither there is any log file generated.

Regards

Ron Grabowski

12/26/2005 5:20 PM  

Logging was working ok for 3 days now it has stopped? When you try to
view log4net's debug messages do you use the system.diagnostics node in
the web.config or do you use DebugView. I've had issues with DebugView
not always showing all the debug messages.

Does your application continue to work ok on your dev machine or has
that stopped working as well?

S. K Rahman

12/27/2005 8:28 AM  

On 12/26/05, Ron Grabowski <rongrabowski@yahoo.com> wrote:
> Logging was working ok for 3 days now it has stopped? When you try to
> view log4net's debug messages do you use the system.diagnostics node in
> the web.config or do you use DebugView. I've had issues with DebugView
> not always showing all the debug messages.
>

Actually I have two application that use log4net. When I posted the
mail earlier. Both of them where not working. Now the first one works
but not the second one. In the first and second case it was permission
issue which I applied to both later. Now the first app works fine but
not the second one.
Both are using the same debug version of log4net that I compiled in
the developer machine and yes I am using the debugview and enabled
log4net internal debugging from web.config as well as set the
debug=true in the config file.

What confuses me is that in debugview I can see the diagnostic
messages first app but nothing relevant to second app. I deliberately
removed the applied permission to second app hoping to get some
relevant debug messages but it did not happen anyway.

> Does your application continue to work ok on your dev machine or has
> that stopped working as well?
>

Yes in the dev machine both of them work fine.

Regards

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Log4net does not works in production env



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement