Solved

Exception in Log4Net

Posted on 2016-11-10
1
19 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 32

Accepted Solution

by:
ste5an earned 500 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Pass through dll 2 37
C# Update Status Bar.... 1 24
cs.Designer Issue(2) 2 21
C# TextBox 11 12
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now