David Thielen | 1 Oct 2005 23:32
Favicon
Gravatar

Anyone want to handle posting a log4j -> log4net wrapper on sourceforge?

Hi;

I am working on some java code that we are porting to J#. Our goal is to
have a common code base so we want to be able to call the log4j classes that
we have throughout our code.

However, we do not want to port log4j as log4net exists, and is widely used
in the .net world. So I am creating a wrapper that is the public log4j
classes that underneath calls log4net. I think this would be very useful to
anyone trying to have a single codebase for J# and java.

I asked the log4net group if they wanted it - but no answer. So is there
someone out there who would be willing to set up a SourceForge project for
this?

Thanks - dave

David Thielen

303-499-2544

 <http://www.windwardreports.com> www.windwardreports.com

Georg Jansen | 3 Oct 2005 14:32

RE: How to pass integrated security credentials to AdoNetAppender from ASP.NET?

Billy,

I forgot to mention in my previous response, that I did move the code back
into the Application_Start event - but I did not use impersonating. I am no
expert on this but as fare as I have understood this; The Application_Start
runs under the aspnet process user, no mater if you are using impersonating
or not. 

When it comes to choosing how to login/connect/store login information, well
that's actually a question about security policy in the company you are
working for. Storing password in clear text in config files is usually never
considered as a good choice. Storing it inside a program is safer than a
text file, but a program can be reverse engineered. You could use an "anti
reverse engineering tool" - to make it harder to break. But you also have a
maintenance problem - passwords should be changed from time to time.

A couple of additional alternatives you may want to consider:

Store the password/user information encrypted a separate config file, the
.NET has pretty good support for encryption (as far as I know) and it should
be fairly easy to implement.

When it comes to logging, you could put the log table in a separate
database, and give the ASPNET access only to that database. If you prefer to
log to separate tables from different applications you need to define
several tables.

If you prefer to keep the log table in the same database as the application
uses, you could grant the ASPNET user access to (and only to) the log table.
Create a stored procedure for inserting rows to the log table, and grant
(Continue reading)

Billy Barnum | 3 Oct 2005 15:56
Picon

RE: How to pass integrated security credentials to AdoNetAppender from ASP.NET?

Thanks, Georg.

Yes, Application_Start only runs under ASPNET, as I learned during this
whole exercise. That's why you worked just fine by granting ASPNET dbms
access and I didn't - I was granting to the anonymous user and my database
was on a physically separate box from the web server. 

As I said, I'm a middle-tier and database guy new to log4net roped into
providing logging for a web app; I sure learned about ASP, here. We are
currently debating the very 2 suggestions you made about different dbmss and
selective grants - great minds think alike!

Anyway, I think we've about beaten this one to death. Thanks again.

-BillyB

Craig Boland | 4 Oct 2005 01:43
Picon
Favicon

RE: How to pass integrated security credentials to AdoNetAppender from ASP.NET?

Connecting to a database with integrated security from a web app is all
about the identity of the process (I know you all are aware of this, I'm
just providing context for the message). And the way this is done, well,
depends on how the application is configured. I've outlined some steps
you'll need to take to get this set up.

1. Create A Domain Service Account
Create a service account in your domain for your application. It could be a
workgroup or machine account, but domain accounts offer a wider scope on the
network. I don't often see this done, but as time goes by I see the value of
an application service account more and more. In fact, if you install any
server products by Microsoft, the installation guide often recommends doing
this.

2. Grant Database Permissions to the Service Account
Create a login account in the database for the service account and give
appropriate permissions. Nothing special here.

3. Configure Applications to Run Under the Service Account
If you're running on Windows Server 2003, you've got it easy. Simply
configure the identity of the Application Pool to which your web app is
assigned and enable impersonation. The ASP.NET process (w3p.exe) will now
run using the credentials of the service account.

If you're running on Windows Server 2000, you'll need to jump thru the
traditional hoops depending on how the site is configured. If you have an
Anonymous-only site, you can set the anonymous identity in the virtual
directory to be the service account from above. In all other cases (Windows
or Basic authentication), you'll need to configure the <identity> element in
web.config to use the username/password of the service account. I know this
(Continue reading)

depsi programmer | 4 Oct 2005 06:39
Picon
Favicon

TypeInitializationException was unhandled

Hi

I am getting following error in log4.net

The exact error message and stack trace:

System.TypeInitializationException was unhandled

 Message="The type initializer for
'log4net.Core.LoggerManager' threw an exception."

 Source="log4net"

 TypeName="log4net.Core.LoggerManager"

 StackTrace:

      at
log4net.Core.LoggerManager.GetRepository(Assembly
repositoryAssembly)

      at log4net.LogManager.GetRepository(Assembly
repositoryAssembly)

      at log4net.Config.XmlConfigurator.Configure()

      at System.Windows.Forms.Form.OnLoad(EventArgs e)

      at System.Windows.Forms.Form.OnCreateControl()

(Continue reading)

Ron Grabowski | 6 Oct 2005 05:37
Picon
Favicon

RE: How to log EventID with EventLogAppender?

Looks like there's already an issue open for this:

 http://issues.apache.org/jira/browse/LOG4NET-38

--- Ron Grabowski <rongrabowski <at> yahoo.com> wrote:

> --- Billy Barnum <b.barnum <at> comcast.net> wrote:
> 
> > Right. Log4Net error msgs all have the same eventId. This is
> exactly
> > what I
> > want to change.
> 
> The documentation for the EventLogAppender says:
> 
> "
> If the event has an EventID property set then this integer will be
> used
> as the event log event id.
> "
> 
> which means if you set an EventID property:
> 
>  log4net.ThreadContext.Properties["EventID"] = 5;
> 
> That value will be sent to the Event Log. I may have used incorrect
> casing on EventID in one of my earlier posts.
> 
> > I'm certainly no EventLog guru, but what I know is this: EventId is
> > not a PK
(Continue reading)

Nicko Cadell | 7 Oct 2005 19:24

RE: TypeInitializationException was unhandled

What type of application are you building? From the look of the call
stack it looks like some kind of VS add-in. If so which version of VS?
I can't reproduce this with a simple forms app so it may be some
interaction with the hosting process.

Is it possible for you to post the source to a bare bones version of
your app? Just something that it launched in the same way, has a form
which is displayed, and calls XmlConfigurator.Configure from the OnLoad
method. If I can reproduce the problem it is much easier to fix.

Cheers,
Nicko

> -----Original Message-----
> From: depsi programmer [mailto:depsi_programmer <at> yahoo.com] 
> Sent: 04 October 2005 05:40
> To: Log4NET User
> Subject: TypeInitializationException was unhandled
> 
> Hi
> 
> I am getting following error in log4.net
> 
> The exact error message and stack trace:
> 
> System.TypeInitializationException was unhandled
> 
>  Message="The type initializer for
> 'log4net.Core.LoggerManager' threw an exception."
> 
(Continue reading)

Nicko Cadell | 7 Oct 2005 19:59

RE: How to log EventID with EventLogAppender?

The Event Category is different to the EventID. The EventLogAppender
already supports setting the EventID, but it does not allow the Category
to be set. That is what LOG4NET-38 is about.

But just because the EventLogAppender supports setting the EventID
doesn't mean that it is easy to pass it the EventID to use, which is the
problem that Billy was having. The EventID must be passed in a property
which can be done either by setting a ThreadProperty or by using the
EventID extension that sets a LoggingEvent Property.

Nicko

> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski <at> yahoo.com] 
> Sent: 06 October 2005 04:38
> To: Log4NET User
> Subject: RE: How to log EventID with EventLogAppender?
> 
> Looks like there's already an issue open for this:
> 
>  http://issues.apache.org/jira/browse/LOG4NET-38
> 
> --- Ron Grabowski <rongrabowski <at> yahoo.com> wrote:
> 
> > --- Billy Barnum <b.barnum <at> comcast.net> wrote:
> > 
> > > Right. Log4Net error msgs all have the same eventId. This is
> > exactly
> > > what I
> > > want to change.
(Continue reading)

jcmag | 7 Oct 2005 20:55
Picon
Favicon

different levels for appenders

Hello,

I would like to know if different appenders could have
different levels of logging.
In my project I have a RollingLogFile appender and an
EventLog appender; I would like to log all messages
(level=ALL) in the file and only ERROR messages in the
eventLog, is it possible ?

Thanks 

JC

		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

Shireesh Thanneru | 7 Oct 2005 21:09
Picon
Favicon

Re: different levels for appenders

Yes, that is possible.
 
Here is how you can do that. Notice the <threshold> tag for the EventLogAppender.

 

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

<file value="rolling-log-file.log" />

<appendToFile value="true" />

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

<maximumFileSize value="100KB" />

<maxSizeRollBackups value="10" />

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

<conversionPattern value="%date{ISO8601} %-5level %logger - %message%newline" />

</layout>

</appender>

 

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

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

<conversionPattern value="%date{ISO8601} %-5level %logger - %message%newline" />

</layout>

<threshold value="ERROR" />

</appender>

<root>

<level value="ALL" />

<appender-ref ref="RollingFileAppender" />

<appender-ref ref="EventLogAppender" />

</root>

 

Thanks,

 

Shireesh Thanneru


jcmag <jcmag <at> yahoo.com> wrote:
Hello,

I would like to know if different appenders could have
different levels of logging.
In my project I have a RollingLogFile appender and an
EventLog appender; I would like to log all messages
(level=ALL) in the file and only ERROR messages in the
eventLog, is it possible ?

Thanks

JC



__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

Gmane