Which codes needed in Using Logging Application Block

Topics: Logging Application Block
Jan 28, 2008 at 8:33 AM

hi everybody,

I wanna use Logging Application Block(LAB) with my multi tier Application(6 tier) which contain Client & Server, and each of them(Client & Server) has its own Configuration File,

I'm Completely new to EL v3.0, what I Undestand from Logging Application Block is that it produce or change the config files, depends on our changes in Enteprise Library Configuration, and then what programming in my application is needed? (ofcourse I mean after adding necessary references)

does any one can help me, about what should i do exactly to use this LAB for my application to produce some kind of logs, not just in eventLog!, I wanna produce for example 3 different logs, for debugging, Error, and tracing my App taransaction with database, furthermore i wanna produce these logs in textfiles and also to one table in my database.
i dont know what codes are necessary in my program, and whether the server or client or both Config File should have changes?
thanks,

elham

Jan 28, 2008 at 4:35 PM
You can start by looking at the Logging Block's scenarios in the help file and the Logging quick starts that you can install through the source code installer.
To specify the configuration for the block, using the EntLib configuration tool is usually the easiest way.

You'll need to add calls to one of the overrides for the Logger.Write() method. Which override to use depends on how much information you want to log. Your apps' configuration settings will determine how these entries will be logged: destination, formatting, etc.

Fernando
Jan 28, 2008 at 10:00 PM
Edited Jan 28, 2008 at 10:07 PM
As OP, am completely new to EL. You mention the help file and quickstarts, but after installation I find that there are no such things! Unless I am looking in the wrong place. In C:\Program Files\Microsoft Enterprise Library 3.1 - May 2007\Docs there are no actual docs. Except for release notes, which are nice but of little value to me. Was there something else to install that I didn't download? What I have is "Enterprise Library May 2007.msi" I noticed nothing else to download, except a EnterpriseLibrary.chm which is apparently damaged and has no actual content, as far as I can tell.

NEVERMIND. I just found it. The docs were installed in a different folder, C:\EntLib3Src.

It would have been nice if these had been installed in the Docs folder of the Enterprise Library instead of someplace completely off the beaten path.
Jan 28, 2008 at 11:06 PM
If you installed the MSI, there should be a shortcut to the integrated help for Enterprise Library in the group your programs menu.

To use the stand alone chm you need to "Unblock" it. It's the OS that is refusing to show the content from a downloaded file; just right click it, Properties, Unblock (IIRC).

The source code for the quickstarts are installed with the source code installer, as I mentioned in my previous post.

Hope this helps, even if it's terse,
Fernando
Jan 29, 2008 at 6:17 AM
hi,
thanks fsimonazzi,
I read their senarios in help and nearly understood what it said, but i just confused in writing codes in my application, for example the codes for first scenario is like this:
LogEntry logEntry = new LogEntry();
logEntry.EventId = 100;
logEntry.Priority = 2;
logEntry.Message = "Informational message";
logEntry.Categories.Add("Trace");
logEntry.Categories.Add("UI Events");

Logger.Write(logEntry);

and it dosent explain any more about it,
I also made the config file but it seems these codes aren't enough for my app to write log,
and there is no trace.log in my computer!!!
however i think i should overrides the Logger.Write() method as you said, i'll try it.
thanks alot.
Jan 29, 2008 at 6:08 PM
Hi,

The code snippet you wrote should be enough to write to a log if the configuration for the logging block specifies that any of these categories ("Trace" and "UI Events") maps to a file trace listener.

I suggest you start with the quick start, see that it does log, and move up from there (ie configure the block to log to your desired destinations)

Fernando