Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Exception in Log4Net

Posted on 2016-11-10
1
Medium Priority
?
121 Views
Last Modified: 2016-11-11
I need to log all stack of my exceptions using log4net.

<appender name="RollingFileErro" type="log4net.Appender.RollingFileAppender">
    <file value="C:\LOGS\Erro.log" />
    <appendToFile value="true" />
    <maximumFileSize value="500KB" />
    <maxSizeRollBackups value="2" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %level %logger - %message%newline" />
    </layout>
  </appender>

Open in new window


How can I log all stack of my exceptions?
0
Comment
Question by:berechit
1 Comment
 
LVL 36

Accepted Solution

by:
ste5an earned 2000 total points
ID: 41883466
You need to catch your exceptions and log it..

Take a look at the examples folder:

try
{
	Bar();
}
catch(Exception ex)
{
	// Log an error with an exception
	log.Error("Exception thrown from method Bar", ex);
}

Open in new window


The Error() method appends the stack trace.

When using PatternLayout Class, then use %stacktrace or %stacktracedetail in your format string.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question