Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Exception in Log4Net

Posted on 2016-11-10
1
Medium Priority
?
100 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

688 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