Where i can get details about LogEntry Members

Topics: Logging Application Block
Oct 9, 2009 at 5:54 AM

hi,

I am new to Enterprise Logging.  I want to get the details about LogEntry class and its Members.

Can any one tell me the url.

Thanks in Advance!

 

Regards,

Baskaran R

Oct 9, 2009 at 6:14 AM

I can't find the url but if you installed enterprise library in your machine, it's available in the documentation.  Just go to the Index tab and search for LogEntry.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 9, 2009 at 11:52 AM

Hi,

Where we have to specify the listener name to write the log.

I have developed two classes Class1.cs and Class2.cs file with Enterprise Logging.

I want to write Class1.cs logs to one log file and Class2.cs logs to another log file.

Is it possible?

Thanks in Advance!

Oct 12, 2009 at 3:58 AM

Yes it is possible. You would need to create 2 category, ex: Class1Category and Class2Category. You would also need to add the tracelisteners, and associate them with your category. ex: I add a flatfile trace listener then associate it with the Class1Category and add another tracelistener and associate it with Class2Category.

To associate a listener to a Category:

  1. Add a category.
  2. In the category, right-click > New > Trace Listener Reference
  3. In the property of the Trace Listener Reference, select the tracelistener that you want to associate.
  4. Save.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 12, 2009 at 5:29 AM
Edited Oct 12, 2009 at 6:57 AM

Thanks a lot.

One more doubt here.

Two teams working in a .net project.  We want to maintain a separate Config file for our <loggingConfiguration> like <appSettings file="appSettingsConf.Config"/>.

And also one more team maintaing their <loggingConfiguration> enteries in Web.Config.  Is it possible to have <loggingConfiguration> in Web.config and also in Separate Config file. 

Thanks in advance!

 

 

Oct 12, 2009 at 6:53 AM

Hi,

The first item is possible, please see this: http://blogs.msdn.com/tomholl/archive/2006/04/02/entlib2externalconfig.aspx  . In your second item, why not just move the logging settings from the web config to the external config.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 12, 2009 at 7:04 AM

Hi,

I think i am not clear with my question. 

tech team 1 maintaing the web.config.

we are tech team2 integrating our product to tech team1's product. So we want to maintain our <loggingConfiguration> data's in a separate file without disturbing tech team1's web.config.

Is it possible?

Oct 12, 2009 at 8:40 AM

Hi,

I dont think that would be possible. because there could only be one active config source. However, there is a workaround that you can do, when logging, you would need to change a bit of code to specify where the configuration must be picked up. in your case, it must be on a external config file. Here is a sample code, where you specify the config file and resolving a LogWriter object.

 

IConfigurationSource source = new FileConfigurationSource("App.config"); //specify the path of the external config
LogWriterFactory factory = new LogWriterFactory(source);
LogWriter writer = factory.Create();
LogEntry entry = new LogEntry();
entry.Message = "HELLO ENT LIB.";
writer.Write(entry);
Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Oct 12, 2009 at 9:47 AM
Edited Oct 12, 2009 at 11:26 AM

Hi,

Thanks a lot.

I have done whatever you told and got the solution.

But some times after i edit the config/aspx file, log file newly created like "e53f90e2-7d30-45d0-a7f1-1b549214f2bf<listener's fileName>", prefixing some junk chars with the filename.

 

 

 

Oct 12, 2009 at 11:24 AM
Edited Oct 12, 2009 at 11:25 AM

Hi,

Please add the line that is on bold.

            IConfigurationSource source = new FileConfigurationSource("App.config");
            LogWriterFactory factory = new LogWriterFactory(source);
            LogWriter writer = factory.Create();
            LogEntry entry = new LogEntry();
            entry.Message = "HELO ENT LIB.";
            writer.Write(entry);
            writer.Dispose();

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 12, 2009 at 11:42 AM

hi,

Once again thank you.  I have one more doubt. I am getting the following SectionInformation using

IConfigurationSource source = new FileConfigurationSource("App.config");

ConfigurationSection configSection= source.GetSection("Settings1");
   
   SectionInformation secInfo = configSection.SectionInformation;

 But i cant find a way to get the value of  keys.  I cant use appSettings here(becoz we have lot of sections like <Settings1>, so we are using Separate Sections)

<Settings1>  
   <!-- Portal Admin Database Details-->
  <add key ="Server" value ="server1"/>
  <add key ="User" value="sa"/>
  <add key ="Pwd" value="sa"/>
  <add key ="Database" value="db1"/>
 
  <add key="Path" value="D:\folder1\"/>
 </Settingss>

Oct 13, 2009 at 2:15 AM

That's your own custom configuration, right? Did you write configuration classes for it?  If you did, you should be able to cast it to your specific configuration section like this:

MySettingsSection settings = (MySettings)source.GetSection("Settings1");

If you didn't here's a link on how to create custom configuration sections: http://msdn.microsoft.com/en-us/library/2tw134k3.aspx

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 13, 2009 at 5:29 AM

Hi,

Ya i have idea about create Custom Configuration Sections, but we use only key- value pairs in Our Custom Configuration( NameValueCollection type Section).

Can you explain me little bit clear to create Custom Section with a type of NameValueCollection.

 

Is it possible?

 

 

Oct 13, 2009 at 6:16 AM

Yes, check this out for the sample code - http://threeisit.com/post/KeyValue-Pair-Configuration-Section.aspx

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 13, 2009 at 7:57 AM

Thanks a lot.

Finally developed a custom class for Key-Value Pair Configuratin Section.

Will implement logging in our product and get back to you for further assistance.