RE: Using AdoNetAppender

2009-06-16 Thread James Green
Hi Ron,
 
I did actually spot this just after posting the code and it did remove
the connection error I was seeing.
 
However, we have got it logging the date values now, however the other
fields are @log_level etc ... are still null.
 
Any ideas?
 
Cheers,
 
James.

  _  

From: Ron Grabowski [mailto:rongrabow...@yahoo.com] 
Sent: 15 June 2009 22:01
To: Log4NET User
Subject: Re: Using AdoNetAppender


If you don't specify a ConnectionType AdoNetAppender defaults to using
OleDbConnection which has a different connection string format than the
more common SqlConnection. Are you sure you want to use OleDbConnection?

Why not write a simple ConsoleApplication to test your code and look at
the configuration output log4net writes to Console.Out?

class Program
{
private static AdoNetAppender _sqlDatabaseAppender = new
AdoNetAppender();

static void Main(string[] args)
{
LogLog.InternalDebugging = true;
LogLog.EmitInternalMessages = true;

ConfigureDatabaseAppender(...);

ILog log = LogManager.GetLogger(typeof(Program));
log.Debug(Hello World);

Console.ReadLine();
}

public static void ConfigureDatabaseAppender(string connString)
{
// snip



  _  

From: James Green james.gr...@occam-dm.com
To: Log4NET User log4net-user@logging.apache.org
Sent: Monday, June 15, 2009 12:04:16 PM
Subject: RE: Using AdoNetAppender


I think I'm going to have to try the config file method first.
 
I'm wrapping log4net and I don't want to cause every consuming component
to require loads of config information in it just for logging purposes.
 
Everything else is a sinch to configure in code, save for this appender
... *sigh* ...
 
Cheers,
 
James.

scanned by MessageLabs [www.messagelabs.com]



RE: Using AdoNetAppender

2009-06-16 Thread James Green
Hi Again,
 
Surely, this is all pointing to a far bigger problem.  That is an
horrific piece of code!!  Surely this is doable in pure C#?
 
I'm amazed that this AdoNetAppender is so poorly documented and has so
few examples.  It's starting to put me off log4net!
 
James.

  _  

From: Ron Grabowski [mailto:rongrabow...@yahoo.com] 
Sent: 15 June 2009 22:32
To: Log4NET User
Subject: Re: Using AdoNetAppender


This page shows an example of loading an xml string into an XmlDocument
then configure log4net from the XmlDocument:

http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Appender/Ad
oNetAppenderTest.cs?view=co

  _  

From: James Green james.gr...@occam-dm.com
To: Log4NET User log4net-user@logging.apache.org
Sent: Monday, June 15, 2009 12:04:16 PM
Subject: RE: Using AdoNetAppender


I think I'm going to have to try the config file method first.
 
I'm wrapping log4net and I don't want to cause every consuming component
to require loads of config information in it just for logging purposes.
 
Everything else is a sinch to configure in code, save for this appender
... *sigh* ...
 
Cheers,
 
James.

scanned by MessageLabs [www.messagelabs.com]



Re: Using AdoNetAppender

2009-06-16 Thread Wayne Douglas
why don't you write a fluent interface for it!?!?

I think that for FREE software provided with SOURCE - it's a pretty darn
good tool at a pretty darn good price - and so does the rest of the _whole_
industry - it being an _industry_ _standard_!

There are plenty of other loggers out there too - for free - open source -
some good some not so good - all off the backs of some very hard work by
some very tallented and commited people.

w://

On Tue, Jun 16, 2009 at 9:48 AM, James Green james.gr...@occam-dm.comwrote:

  Hi Again,

 Surely, this is all pointing to a far bigger problem.  That is an horrific
 piece of code!!  Surely this is doable in pure C#?

 I'm amazed that this AdoNetAppender is so poorly documented and has so few
 examples.  It's starting to put me off log4net!

 James.

  --
 *From:* Ron Grabowski [mailto:rongrabow...@yahoo.com]
 *Sent:* 15 June 2009 22:32
 *To:* Log4NET User
 *Subject:* Re: Using AdoNetAppender

  This page shows an example of loading an xml string into an XmlDocument
 then configure log4net from the XmlDocument:


 http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Appender/AdoNetAppenderTest.cs?view=co

  --
 *From:* James Green james.gr...@occam-dm.com
 *To:* Log4NET User log4net-user@logging.apache.org
 *Sent:* Monday, June 15, 2009 12:04:16 PM
 *Subject:* RE: Using AdoNetAppender

 I think I'm going to have to try the config file method first.

 I'm wrapping log4net and I don't want to cause every consuming component to
 require loads of config information in it just for logging purposes.

 Everything else is a sinch to configure in code, save for this appender ...
 *sigh* ...

 Cheers,

 James.

 scanned by MessageLabs [www.messagelabs.com]




-- 
Cheers,

w://


Re: Using AdoNetAppender

2009-06-16 Thread Wayne Douglas
No I haven't - and to be fair, I did try doing this a while ago:

code file='global.asax' method='Application_Start'

log4net.Config.XmlConfigurator.Configure();

    //reset the logger to use the default con string - so we
only need to change it on one place
    var hier =
  log4net.LogManager.GetRepository() as
log4net.Repository.Hierarchy.Hierarchy;

    if (hier != null)
    {
    //get ADONetAppender
    var adoAppender =
(log4net.Appender.AdoNetAppender)hier.GetLogger(root,hier.LoggerFactory).GetAppender(AdoNetAppender);
    var adoAppender =
(log4net.Appender.AdoNetAppender)hier.Root.Appenders[0];
    if (adoAppender != null)
    {
    adoAppender.ConnectionString =
AppSettings.GetConfigurationString(MainConnection);
    adoAppender.ActivateOptions(); //refresh settings
of appender
    }
    }

/code

and failed - but this is possibly because of a few things outside the
responsibility of the log4net codebase.

There's nothing wrong working through a poroblem - to help improve the
situ - but just rubbishing it won't help anyone.

w://

On Tue, Jun 16, 2009 at 10:08 AM, James Green james.gr...@occam-dm.com wrote:

 Hi Wayne,

 I didn't wish to start a flame war.

 This is not the first time I've had trouble finding decent log4net docs when 
 configuring without AppConfig, in fact Google hardly returns a thing on this 
 topic.  Surely database logging is one of the most popular features and I'm 
 highlighting what I think to be a massive gap in its documentation.

 I love log4net, it was a no brainer for me to pick but don't think getting 
 this library configured using pure C# is easy.  Have you completed this task 
 without using Xml config?  Xml config is not always possible nor desirable.

 James.
 
 From: codingvi...@googlemail.com [mailto:codingvi...@googlemail.com] On 
 Behalf Of Wayne Douglas
 Sent: 16 June 2009 09:58
 To: Log4NET User
 Subject: Re: Using AdoNetAppender

 why don't you write a fluent interface for it!?!?

 I think that for FREE software provided with SOURCE - it's a pretty darn good 
 tool at a pretty darn good price - and so does the rest of the _whole_ 
 industry - it being an _industry_ _standard_!

 There are plenty of other loggers out there too - for free - open source - 
 some good some not so good - all off the backs of some very hard work by some 
 very tallented and commited people.

 w://

 On Tue, Jun 16, 2009 at 9:48 AM, James Green james.gr...@occam-dm.com wrote:

 Hi Again,

 Surely, this is all pointing to a far bigger problem.  That is an horrific 
 piece of code!!  Surely this is doable in pure C#?

 I'm amazed that this AdoNetAppender is so poorly documented and has so few 
 examples.  It's starting to put me off log4net!

 James.
 
 From: Ron Grabowski [mailto:rongrabow...@yahoo.com]
 Sent: 15 June 2009 22:32
 To: Log4NET User
 Subject: Re: Using AdoNetAppender

 This page shows an example of loading an xml string into an XmlDocument then 
 configure log4net from the XmlDocument:

 http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Appender/AdoNetAppenderTest.cs?view=co
 
 From: James Green james.gr...@occam-dm.com
 To: Log4NET User log4net-user@logging.apache.org
 Sent: Monday, June 15, 2009 12:04:16 PM
 Subject: RE: Using AdoNetAppender

 I think I'm going to have to try the config file method first.

 I'm wrapping log4net and I don't want to cause every consuming component to 
 require loads of config information in it just for logging purposes.

 Everything else is a sinch to configure in code, save for this appender ... 
 *sigh* ...

 Cheers,

 James.
 scanned by MessageLabs [www.messagelabs.com]



 --
 Cheers,

 w://

 scanned by MessageLabs [www.messagelabs.com]



--
Cheers,

w://


RE: Using AdoNetAppender

2009-06-16 Thread James Green
Cracked it ...

AdoNetAppenderParameter logLevel = new
AdoNetAppenderParameter();
logLevel.ParameterName = @log_level;
logLevel.Layout = new Layout2RawLayoutAdapter(new
PatternLayout(%level));
logLevel.Size = 50;
logLevel.DbType = System.Data.DbType.String;
_sqlDatabaseAppender.AddParameter(logLevel);

Regards,

James.


Re: Using AdoNetAppender

2009-06-16 Thread Wayne Douglas
bet that was a 'punching hands in the air' geek moment from hell

On Tue, Jun 16, 2009 at 10:58 AM, James Greenjames.gr...@occam-dm.com wrote:
 Cracked it ...

            AdoNetAppenderParameter logLevel = new
 AdoNetAppenderParameter();
            logLevel.ParameterName = @log_level;
            logLevel.Layout = new Layout2RawLayoutAdapter(new
 PatternLayout(%level));
            logLevel.Size = 50;
            logLevel.DbType = System.Data.DbType.String;
            _sqlDatabaseAppender.AddParameter(logLevel);

 Regards,

 James.




-- 
Cheers,

w://


RE: Using AdoNetAppender

2009-06-16 Thread James Green
 bet that was a 'punching hands in the air' geek moment from hell

Indeed ... I may even make a cup of tea to celebrate! :)

Cheers,

James.


Re: Using AdoNetAppender

2009-06-16 Thread Ron Grabowski
Its quite difficult to document every possible usage of a library. In addition 
to these documents:

http://logging.apache.org/log4net/release/config-examples.html
http://logging.apache.org/log4net/release/sdk/log4net.Appender.AdoNetAppender.html
http://logging.apache.org/log4net/release/sdk/log4net.Appender.AdoNetAppenderParameter.Layout.html

There's about 8,000 search results on Google for AdoNetAppender. 

A lot of the documentation is focused on XML examples because that's how the 
majority of the users configure log4net.

I'll glady add your code configuration examples to AdoNetAppenderTest.cs if 
attach them to a JIRA ticket!





From: James Green james.gr...@occam-dm.com
To: Log4NET User log4net-user@logging.apache.org
Sent: Tuesday, June 16, 2009 4:48:27 AM
Subject: RE: Using AdoNetAppender


Hi Again,
 
Surely, this is all pointing to a far bigger problem.  
That is an horrific piece of code!!  Surely this is doable in pure 
C#?
 
I'm amazed that this AdoNetAppender is so poorly 
documented and has so few examples.  It's starting to put me off 
log4net!
 
James.



 From: Ron Grabowski 
[mailto:rongrabow...@yahoo.com] 
Sent: 15 June 2009 
22:32
To: Log4NET User
Subject: Re: Using 
AdoNetAppender


This page shows an example of loading an xml string into an XmlDocument 
then configure log4net from the XmlDocument:

http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Appender/AdoNetAppenderTest.cs?view=co




 From: James Green 
james.gr...@occam-dm.com
To: Log4NET User 
log4net-user@logging.apache.org
Sent: Monday, June 15, 2009 12:04:16 
PM
Subject: RE: Using 
AdoNetAppender


I think I'm going to have to try the config file method 
first.
 
I'm wrapping log4net and I don't want to cause every 
consuming component to require loads of config information in it just for 
logging purposes.
 
Everything else is a sinch to configure in code, save for 
this appender ... *sigh* ...
 
Cheers,
 
James.
scanned by 
MessageLabs [www.messagelabs.com]


Re: Deleting old logs

2009-06-16 Thread Ron Grabowski

What happens when you add RollingMode value=Size /?

http://logging.apache.org/log4net/release/config-examples.html



- Original Message 
From: M.Suarez moc...@gmail.com
To: log4net-user@logging.apache.org
Sent: Monday, June 15, 2009 5:21:24 PM
Subject: Deleting old logs


Hi,

I am trying to just have the latest 2 log files of my application, thus I
have configured the log4net as follows:

log4net
appender name=RollingFile
type=log4net.Appender.RollingFileAppender
  file value=d:\netapps\logfiles\MyApp.log /
  appendToFile value=true /
MaximumFileSize value=100KB/
MaxSizeRollBackups value=2 /
  lockingModel type=log4net.Appender.FileAppender+MinimalLock /

  layout type=log4net.Layout.PatternLayout
conversionPattern value=%date [%thread] %-5level %logger -
%message%newline /
  /layout
/appender

!-- Set root logger level to INFO and its only appender to Console and
RollingFile--
root
  level value=INFO /
  appender-ref ref=RollingFile /
/root
  /log4net

However, there will be more than then two expected log files, this is
because:
The maximum applies to each time based group of files and not the total 
(http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.MaxSizeRollBackups.html)

How should I configure log4net then to only store the latest two files? Any
help will be greatly appreciate it.

Regards,
Monica
-- 
View this message in context: 
http://www.nabble.com/Deleting-old-logs-tp24042093p24042093.html
Sent from the Log4net - Users mailing list archive at Nabble.com.


Re: Using AdoNetAppender

2009-06-16 Thread Ron Grabowski

You could have also copied the built-in TimeStamp layout

// log4net.Layout
public class RawTimeStampLayout : IRawLayout
{
public object Format(LoggingEvent loggingEvent)
{
return loggingEvent.TimeStamp;
}
}

and made your own Level layout:

public class RawLevelLayout : IRawLayout
{
public object Format(LoggingEvent loggingEvent)
{
return loggingEvent.Level;
}
}



- Original Message 
From: James Green james.gr...@occam-dm.com
To: Log4NET User log4net-user@logging.apache.org
Sent: Tuesday, June 16, 2009 5:58:12 AM
Subject: RE: Using AdoNetAppender

Cracked it ...

AdoNetAppenderParameter logLevel = new
AdoNetAppenderParameter();
logLevel.ParameterName = @log_level;
logLevel.Layout = new Layout2RawLayoutAdapter(new
PatternLayout(%level));
logLevel.Size = 50;
logLevel.DbType = System.Data.DbType.String;
_sqlDatabaseAppender.AddParameter(logLevel);

Regards,

James.



RE: Deleting old logs

2009-06-16 Thread Radovan Raszka
Deleting old log files is thing I'm interested in too.
According to doc I think MaxSizeRollBackups has reason only when logs are 
rolled over size (you have more log files per day).
But it probably doesn't work when log is rolled over date only (one log per day 
only). Is it true or not?
My appender is configured as follows:
appender name=RollingFile type=log4net.Appender.RollingFileAppender 
appendToFile value=true / 
  file value=Log/Service.log / 
  layout type=log4net.Layout.PatternLayout 
 conversionPattern value=%date{HH:mm:ss,fff} %5level [%2thread] 
%message (%logger{1}:%line)%n /
  /layout 
  rollingStyle value=Date / 
  Threshold value=DEBUG / 
/appender 
But I don't know how to set it to keep last 10 logs. Now I delete old logs in 
my app - I run clean procedure once a day and delete logs whose last 
modification was done before 10 days...
Radovan


-Původní zpráva-
Od: Ron Grabowski [mailto:rongrabow...@yahoo.com] 
Odesláno: 17. června 2009 0:05
Komu: Log4NET User
Předmět: Re: Deleting old logs


What happens when you add RollingMode value=Size /?

http://logging.apache.org/log4net/release/config-examples.html



- Original Message 
From: M.Suarez moc...@gmail.com
To: log4net-user@logging.apache.org
Sent: Monday, June 15, 2009 5:21:24 PM
Subject: Deleting old logs


Hi,

I am trying to just have the latest 2 log files of my application, thus I have 
configured the log4net as follows:

log4net
appender name=RollingFile
type=log4net.Appender.RollingFileAppender
  file value=d:\netapps\logfiles\MyApp.log /
  appendToFile value=true /
MaximumFileSize value=100KB/
MaxSizeRollBackups value=2 /
  lockingModel type=log4net.Appender.FileAppender+MinimalLock /

  layout type=log4net.Layout.PatternLayout
conversionPattern value=%date [%thread] %-5level %logger - 
%message%newline /
  /layout
/appender

!-- Set root logger level to INFO and its only appender to Console and
RollingFile--
root
  level value=INFO /
  appender-ref ref=RollingFile /
/root
  /log4net

However, there will be more than then two expected log files, this is
because:
The maximum applies to each time based group of files and not the total 
(http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.MaxSizeRollBackups.html)

How should I configure log4net then to only store the latest two files? Any 
help will be greatly appreciate it.

Regards,
Monica
--
View this message in context: 
http://www.nabble.com/Deleting-old-logs-tp24042093p24042093.html
Sent from the Log4net - Users mailing list archive at Nabble.com.