Solved

Exception in Log4Net

Posted on 2016-11-10
1
40 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 33

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can't disable touch pad on Windows 10 computer 16 45
SSIS On fail action 5 37
linq, c# 8 22
Unlocking a column in excel using C# 17 14
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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