Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedLogging - DNN 7Logging - DNN 7
Previous
 
Next
New Post
10/4/2013 3:49 PM
 

I have been looking into implementing logging on my DNN 7+ site. I would like to have a configurable logging level such as that provided with log4net.

I attempted to follow the instructions to integrate log4net found on the DNN site here, http://www.dnnsoftware.com/community-.... After adding the reference and the line of code to use the logging:

DnnLog.Info("My Logging Worked!");

The code reported a warning that reads:

'DotNetNuke.Instrumentation.DnnLog' is obsolete: '"Depreciated in 7.0.1 due to poor performance, use LoggerSource.Instance"'

I am having a hard time finding information about the right way to do things. It appears that "DnnLog" has been replaced with a similar class to interact with log4net called "DnnLogger". One of the differences with using this class (and the "LoggerSource" class) is that logging is no longer accomplished using static methods.

The "GetLogger()" function used to retrieve the logger instance takes some parameters and I have not yet been able to find any documentation describing the appropriate usage. The DNN source has plenty of examples. From these examples it looks like the appropriate usage is to supply the current class. Inside a file "MyClass.cs" that declares a class "MyClass" it appears the following would be correct:

ILog logger = LoggerSource.Instance.GetLogger(typeof(MyClass));

or

DnnLogger logger = DnnLogger.GetLogger("MyClass");

What logger is returned by the first line of code that uses the typeof()? By this I mean, will this logger then be using the log4net settings configured for the site? If it isn't using the log4net settings, where are the log files saved and where are configuration settings adjusted? The nerd in me wants to know exactly what is happening with the typeof() class parameter, why is it used?

If the first example does not connect with log4net (or something that allows a configurable easy to use logging level), is the second option the way to go? If so, what is the appropriate string to be passing? "MyClass" was my guess but I could not confirm.

If I am totally off track here and should be approaching this from another direction please feel free to chime in with suggestions.

Thanks a lot everyone!

 
New Post
10/7/2013 6:46 PM
 
the ILog/dnnlogger classes all both using log4net configuration - we recommend using the loggersource versions as they are slightly better performing (and also have better separation so can help with writing unit tests). The class type passed in the static method just creates a logger for that class, which allows it to have better performance (i.e. not 1 logger for all files), as well as preserve the correct exception startpoint (in case it was not obvious via the stacktrace)

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedLogging - DNN 7Logging - DNN 7


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out