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 Henning Støverud <he...@stoverud.no> on 2009/08/17 11:25:02 UTC

Adding a new column

Hi,

 

I’m using ADONetAppender and now I want to add a separate column where I can
automatically log a customer ID for each log entry. How do I go about to
implement this? 

 

/Henning

 

 


RE: Adding a new column

Posted by Henning Støverud <he...@stoverud.no>.
Sound like this could work! I’ll give it a try. Thanks :)

 

 

From: Karim Bourouba [mailto:karym6@hotmail.com] 
Sent: 17. august 2009 12:03
To: log4net-user@logging.apache.org
Subject: RE: Adding a new column

 

Ok, so you need to do two things. 

  

First you need to figure out what you want your schema to look like, I would
suggest having a field called CustID or something - you can choose. How you
want this field to behave is up to you, for instance do you want it to be
nullable? 

  

One you have done that, look into the snippet of code I mailed earlier. You
can capture custom properties with log4net, one of these can be the value
you wish to put in your DB. 

  

How does this sound to you?



  

  _____  

From: henning@stoverud.no
To: log4net-user@logging.apache.org
Subject: RE: Adding a new column
Date: Mon, 17 Aug 2009 11:46:56 +0200

I want to add a new column to the DB schema so that I can log customer IDs
as a separate colum.

 

The table currently looks like this:

 

Id        int        

Date    datetime          

Thread varchar(255)   

[Level]            varchar(50)     

Logger            varchar(255)   

Message          varchar(4000) 

Exception       varchar(2000) 

Context           varchar(255)   

 

I want to add a new column and modify log4net to write a specific value to
the new column for all new log messages.

 

Then I want to either overload the logging methods so I can manually specify
a customer ID as a parameter like this:

log.Info(customerId, ”This is a customer specific log message”,
someException);

 

Or maybe pick up the customer ID automatically based on a session variable
or something.

 

 

 

 

From: Karim Bourouba [mailto:karym6@hotmail.com] 
Sent: 17. august 2009 11:38
To: log4net-user@logging.apache.org
Subject: RE: Adding a new column

 

Do you mean adda new column to be logged? If you do, then you can use
&property(MY CUSTOM PROPERTY HERE) in the config file. Complimented with
log4net.GlobalContext.Properties["taskname"] = _taskName; in your code to
capture your custom column name (assuming it is called "taskname". 

  

If you are talking about your DB, then thats something outwith log4net I
think.



  

  _____  

From: henning@stoverud.no
To: log4net-user@logging.apache.org
Subject: Adding a new column
Date: Mon, 17 Aug 2009 11:25:02 +0200

Hi,

 

I’m using ADONetAppender and now I want to add a separate column where I can
automatically log a customer ID for each log entry. How do I go about to
implement this? 

 

/Henning

 

 

 

  _____  

Windows Live Messenger: Happy 10-Year Anniversary—get free winks and
emoticons. Get Them Now <http://clk.atdmt.com/UKM/go/157562755/direct/01/> 

 

  _____  

Celebrate a decade of Messenger with free winks, emoticons, display pics,
and more. Get Them <http://clk.atdmt.com/UKM/go/157562755/direct/01/>  Now


RE: Adding a new column

Posted by Karim Bourouba <ka...@hotmail.com>.
Ok, so you need to do two things.
 
First you need to figure out what you want your schema to look like, I would suggest having a field called CustID or something - you can choose. How you want this field to behave is up to you, for instance do you want it to be nullable?
 
One you have done that, look into the snippet of code I mailed earlier. You can capture custom properties with log4net, one of these can be the value you wish to put in your DB.
 
How does this sound to you?



 



From: henning@stoverud.no
To: log4net-user@logging.apache.org
Subject: RE: Adding a new column
Date: Mon, 17 Aug 2009 11:46:56 +0200







I want to add a new column to the DB schema so that I can log customer IDs as a separate colum.
 
The table currently looks like this:
 
Id        int        
Date    datetime          
Thread varchar(255)   
[Level]            varchar(50)     
Logger            varchar(255)   
Message          varchar(4000) 
Exception       varchar(2000) 
Context           varchar(255)   
 
I want to add a new column and modify log4net to write a specific value to the new column for all new log messages.
 
Then I want to either overload the logging methods so I can manually specify a customer ID as a parameter like this:
log.Info(customerId, ”This is a customer specific log message”, someException);
 
Or maybe pick up the customer ID automatically based on a session variable or something.
 
 
 
 



From: Karim Bourouba [mailto:karym6@hotmail.com] 
Sent: 17. august 2009 11:38
To: log4net-user@logging.apache.org
Subject: RE: Adding a new column
 
Do you mean adda new column to be logged? If you do, then you can use &property(MY CUSTOM PROPERTY HERE) in the config file. Complimented with log4net.GlobalContext.Properties["taskname"] = _taskName; in your code to capture your custom column name (assuming it is called "taskname". 
  
If you are talking about your DB, then thats something outwith log4net I think.



  



From: henning@stoverud.no
To: log4net-user@logging.apache.org
Subject: Adding a new column
Date: Mon, 17 Aug 2009 11:25:02 +0200

Hi,
 
I’m using ADONetAppender and now I want to add a separate column where I can automatically log a customer ID for each log entry. How do I go about to implement this? 
 
/Henning
 
 
 



Windows Live Messenger: Happy 10-Year Anniversary—get free winks and emoticons. Get Them Now
_________________________________________________________________

Upgrade to Internet Explorer 8 Optimised for MSN.  

http://extras.uk.msn.com/internet-explorer-8/?ocid=T010MSN07A0716U

RE: Adding a new column

Posted by Henning Støverud <he...@stoverud.no>.
I want to add a new column to the DB schema so that I can log customer IDs
as a separate colum.

 

The table currently looks like this:

 

Id        int        

Date    datetime          

Thread varchar(255)   

[Level]            varchar(50)     

Logger            varchar(255)   

Message          varchar(4000) 

Exception       varchar(2000) 

Context           varchar(255)   

 

I want to add a new column and modify log4net to write a specific value to
the new column for all new log messages.

 

Then I want to either overload the logging methods so I can manually specify
a customer ID as a parameter like this:

log.Info(customerId, ”This is a customer specific log message”,
someException);

 

Or maybe pick up the customer ID automatically based on a session variable
or something.

 

 

 

 

From: Karim Bourouba [mailto:karym6@hotmail.com] 
Sent: 17. august 2009 11:38
To: log4net-user@logging.apache.org
Subject: RE: Adding a new column

 

Do you mean adda new column to be logged? If you do, then you can use
&property(MY CUSTOM PROPERTY HERE) in the config file. Complimented with
log4net.GlobalContext.Properties["taskname"] = _taskName; in your code to
capture your custom column name (assuming it is called "taskname". 

  

If you are talking about your DB, then thats something outwith log4net I
think.



  

  _____  

From: henning@stoverud.no
To: log4net-user@logging.apache.org
Subject: Adding a new column
Date: Mon, 17 Aug 2009 11:25:02 +0200

Hi,

 

I’m using ADONetAppender and now I want to add a separate column where I can
automatically log a customer ID for each log entry. How do I go about to
implement this? 

 

/Henning

 

 

 

  _____  

Windows Live Messenger: Happy 10-Year Anniversary—get free winks and
emoticons. Get Them <http://clk.atdmt.com/UKM/go/157562755/direct/01/>  Now


RE: Adding a new column

Posted by Karim Bourouba <ka...@hotmail.com>.
Do you mean adda new column to be logged? If you do, then you can use &property(MY CUSTOM PROPERTY HERE) in the config file. Complimented with log4net.GlobalContext.Properties["taskname"] = _taskName; in your code to capture your custom column name (assuming it is called "taskname".
 
If you are talking about your DB, then thats something outwith log4net I think.



 



From: henning@stoverud.no
To: log4net-user@logging.apache.org
Subject: Adding a new column
Date: Mon, 17 Aug 2009 11:25:02 +0200





Hi,
 
I’m using ADONetAppender and now I want to add a separate column where I can automatically log a customer ID for each log entry. How do I go about to implement this? 
 
/Henning
 
 
_________________________________________________________________
Windows Live Messenger: Happy 10-Year Anniversary—get free winks and emoticons.
http://clk.atdmt.com/UKM/go/157562755/direct/01/