Keith Farris | 2 Aug 19:51 2007
Picon

Using LoggerMatchFilter

I'm looking for a good config example of using LoggerMatchFilter.  I am trying to separate difference
namespaces into separate logfiles and I see lots of references to LoggerMatchFilter and Repository but I
can't find any practical examples that actually get them to work.

       
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow  

Ron Grabowski | 3 Aug 04:33 2007
Picon

Re: Add or change parameter value dynamicly

Is your ProcessID a special variable that isn't available during startup or do you just want to include the
%processid pattern?

----- Original Message ----
From: arsenmkrt <mkrtchyan.arsen <at> gmail.com>
To: log4net-user <at> logging.apache.org
Sent: Tuesday, July 31, 2007 8:16:43 AM
Subject: Add or change parameter value dynamicly

Hello. I have a table T_Audit where i want to write my log messages in oracle
db. it has a field processid that i want to put dynamically its the
identifier of the process that is doing log not the real process just the id
of process table from my database so i decide to write my appender like this 

 <appender name="AdoNetAppender_Oracle"
type="log4net.Appender.AdoNetAppender">
    <connectionType value="System.Data.OracleClient.OracleConnection,
System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
    <connectionString value="my connection string" />
    <commandText value="INSERT INTO T_AUDIT
(LOG_ID,RM_METADATA_ID,PROCESS_ID,PROCESS_TYPE,LOG_DATE,SEVERITY,LOG_MESSAGE)
VALUES
(SEQ_AUDIT.NEXTVAL,:rmmetadataid,:processid,:processtype,:log_date,:log_level,:message)"
/>
    <bufferSize value="128" />
    <parameter>
      <parameterName value=":rmmetadataid" />
      <dbType value="Int32" />
      <layout type="log4net.Layout.PatternLayout">
(Continue reading)

Ron Grabowski | 3 Aug 04:51 2007
Picon

Re: Disable/enable appender for all loggers

Instead of removing the appender you could just set its threshold to OFF then when you want to enable it again
you can set it back to DEBUG:

// untested
public static void SetThreshold(string appenderName, Level threshold)
{
    foreach (AppenderSkeleton appender in LogManager.GetRepository().GetAppenders())
    {
        if (appender.Name == appenderName)
        {
            appender.Threshold = threshold;
            appender.ActivateOptions();
            break;
        }
    }
}

----- Original Message ----

From: Radovan Raszka <raszka <at> hasam.cz>

To: log4net-user <at> logging.apache.org

Sent: Friday, July 27, 2007 2:23:05 AM

Subject: Disable/enable appender for all loggers

Disable/enable appender for all loggers           Hello,  

I am using three appenders in my log4net configuration (see bellow). But I need programatically disable
(Continue reading)

Ron Grabowski | 3 Aug 04:53 2007
Picon

Re: Disable/enable appender for all loggers

Doh! I keep posted without reading all the messages. John's suggestion
is the same as mine except he posted it a few days earlier.

----- Original Message ----
From: Ron Grabowski <rongrabowski <at> yahoo.com>
To: Log4NET User <log4net-user <at> logging.apache.org>
Sent: Thursday, August 2, 2007 10:51:36 PM
Subject: Re: Disable/enable appender for all loggers

Instead of removing the appender you could just set its threshold to OFF then when you want to enable it again
you can set it back to DEBUG:

// untested
public static void SetThreshold(string appenderName, Level threshold)
{
    foreach (AppenderSkeleton appender in LogManager.GetRepository().GetAppenders())
    {
        if (appender.Name == appenderName)
        {
            appender.Threshold = threshold;
            appender.ActivateOptions();
            break;
        }
    }
}

----- Original Message ----

From: Radovan Raszka <raszka <at> hasam.cz>

(Continue reading)

Ron Grabowski | 3 Aug 04:54 2007
Picon

Re: what will the inlisted changes in log4net code affect

Did you accidently post this to the log4net list or do 1., 2., 3., 5. mean something?

----- Original Message ----
From: pooja rawat <prawat <at> chambal.com>
To: log4net-user <at> logging.apache.org
Sent: Friday, July 27, 2007 9:09:18 AM
Subject: what will the inlisted changes in log4net code affect

1.
remove the extra catch block used
like a catch block from the  code below
catch(Exception ex)
{
log4net.Util.LogLog.Warn("StringFormat: Exception while rendering format
["+format+"]", ex);
return StringFormatError(ex, format, args);
}
catch
{
log4net.Util.LogLog.Warn("StringFormat: Exception while rendering format
["+format+"]");
return StringFormatError(null, format, args);
} 

2.
Change in config.cs
System.Web.HttpContext.GetConfig(string) 
to 
System.Web.HttpContext.GetSection (string)

(Continue reading)

Ron Grabowski | 3 Aug 05:03 2007
Picon

Re: Using LoggerMatchFilter

What have you tried that doesn't work?

This filter should continue to process the log message only if its logger is Company.Project:

<filter type="log4net.Filter.LevelRangeFilter">
 <loggerToMatch value="Company.Project" />
 <acceptOnMatch value="true" />
</filter>

----- Original Message ----
From: Keith Farris <kfarris9 <at> yahoo.com>
To: log4net-user <at> logging.apache.org
Sent: Thursday, August 2, 2007 1:51:23 PM
Subject: Using LoggerMatchFilter

I'm looking for a good config example of using LoggerMatchFilter.  I am trying to separate difference
namespaces into separate logfiles and I see lots of references to LoggerMatchFilter and Repository but I
can't find any practical examples that actually get them to work.

       
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow

arsenmkrt | 3 Aug 06:58 2007
Picon

Re: Add or change parameter value dynamicly


OK i found the solution i just use mdc . I wrote parametr
<parameter>
      <parameterName value=":processid" />
      <dbType value="Int32" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%X{prid}" />
      </layout>
</parameter>
And set the value from my brogram like this
public void SetProcessID(int ProcessID)
{
      MDC.Set("prid", ProcessID.ToString());
}
I found that here

http://weblogs.asp.net/drnetjes/archive/2005/02/16/374780.aspx

Thanks for help.

Ron Grabowski wrote:
> 
> Is your ProcessID a special variable that isn't available during startup
> or do you just want to include the %processid pattern?
> 
> ----- Original Message ----
> From: arsenmkrt <mkrtchyan.arsen <at> gmail.com>
> To: log4net-user <at> logging.apache.org
> Sent: Tuesday, July 31, 2007 8:16:43 AM
> Subject: Add or change parameter value dynamicly
(Continue reading)

Scott Glass | 3 Aug 18:20 2007
Picon

UDP Appender Issues

Hello,

  I’m trying to log events to ChainSaw using the UdpAppender.  However, even after following the directions on the web site I keep getting the message:

 

 

log4net:ERROR [UdpAppender] Unable to send logging event to remote host ::1 on port 8080.

System.Net.Sockets.SocketException: An address incompatible with the requested protocol was used

   at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint remoteEP)

   at System.Net.Sockets.UdpClient.Send(Byte[] dgram, Int32 bytes, IPEndPoint endPoint)

   at log4net.Appender.UdpAppender.Append(LoggingEvent loggingEvent)

A first chance exception of type 'System.NullReferenceException' occurred in com.sungard.servicemanagement.AuthListService_200708.InfoModel.DLL

The thread 0x918 has exited with code 0 (0x0).

 

<appender name="UdpAppender" type="log4net.Appender.UdpAppender">

    <remoteAddress value="127.0.0.1" />

    <remotePort value="8080" />

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

        <locationInfo value="true" />

    </layout>

</appender>

 

Firewall rules are in place to allow UDP:8080 traffic and netStat shows an open listener on port 8080.

 

I’m at a loss, any ideas?

 

Thanks,

Scott

Michael Schall | 3 Aug 18:47 2007
Picon

Re: UDP Appender Issues

I'm not an expert, but I have it working and here is the config.  You
are missing the LocalPort param.  I don't know if it is required.

	<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
		<param name="LocalPort" value="23098" />
		<param name="RemoteAddress" value="127.0.0.1" />
		<param name="RemotePort" value="8888" />
		<layout type="log4net.Layout.XmlLayoutSchemaLog4j, log4net">
			<locationInfo value="true" />
		</layout>
	</appender>

On 8/3/07, Scott Glass <scott.glass <at> gmail.com> wrote:
>
>
>
>
> Hello,
>
>   I'm trying to log events to ChainSaw using the UdpAppender.  However, even
> after following the directions on the web site I keep getting the message:
>
>
>
>
>
> log4net:ERROR [UdpAppender] Unable to send logging event to remote host ::1
> on port 8080.
>
> System.Net.Sockets.SocketException: An address incompatible
> with the requested protocol was used
>
>    at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32
> offset, Int32 size, SocketFlags socketFlags, EndPoint remoteEP)
>
>    at System.Net.Sockets.UdpClient.Send(Byte[] dgram, Int32
> bytes, IPEndPoint endPoint)
>
>    at log4net.Appender.UdpAppender.Append(LoggingEvent
> loggingEvent)
>
> A first chance exception of type 'System.NullReferenceException' occurred in
> com.sungard.servicemanagement.AuthListService_200708.InfoModel.DLL
>
> The thread 0x918 has exited with code 0 (0x0).
>
>
>
> <appender name="UdpAppender" type="log4net.Appender.UdpAppender">
>
>     <remoteAddress value="127.0.0.1" />
>
>     <remotePort value="8080" />
>
>     <layout type="log4net.Layout.XmlLayoutSchemaLog4j">
>
>         <locationInfo value="true" />
>
>     </layout>
>
> </appender>
>
>
>
> Firewall rules are in place to allow UDP:8080 traffic and netStat shows an
> open listener on port 8080.
>
>
>
> I'm at a loss, any ideas?
>
>
>
> Thanks,
>
> Scott

Giovannini, Stephanie | 3 Aug 22:24 2007

Suppress repeated, identical log entries and add a summary log entry

I'm trying to design a custom filter using log4net. I'm in the conceptual stage
of design and I don't see how I can implement the entire design.

The problem is that I want a part of log4net, a filter, to be able to generate
logging entries.

I want to make a filter that will suppress identical log messages from the same
logger if they occur too soon after each other, and then emit a log entry when
the error condition stops. I'll illustrate with an example.

An external device is polled once a second. The device begins to return errors.
The logger calls the Error method. The first error is logged as usual. The
device then returns the exact same error once a second for 10 minutes. The
filter denies all of those entries because they are identical to a log entry
that was logged within a specific expiration period (configurable aspect of
filter, in this example, let's say 2 minutes).

I think I can do what's above. The kicker is the final part, illustrated below.

One expiration period (2 minutes in this example) after the last identical log
entry was denied by the filter, the filter generates a log entry stating that
the error message X had occurred Y times and the last occurrence was at Z time.
This entry should be logged from the same logger that made all the identical log
entries.

I haven't written any code for this because I want to know that it's feasible.
I'm not sure how to get the class that implements IFilter to generate a log
entry from the same logger that submitted the original entries.

Any ideas?

Thanks for reading this...

The information transmitted (including attachments) is
covered by the Electronic Communications Privacy Act,
18 U.S.C. 2510-2521, is intended only for the person(s) or
entity/entities to which it is addressed and may contain
confidential and/or privileged material. Any review,
retransmission, dissemination or other use of, or taking
of any action in reliance upon, this information by persons
or entities other than the intended recipient(s) is prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.



Gmane