Return-Path: Delivered-To: apmail-logging-log4net-dev-archive@www.apache.org Received: (qmail 12531 invoked from network); 7 Feb 2009 13:27:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Feb 2009 13:27:24 -0000 Received: (qmail 29169 invoked by uid 500); 7 Feb 2009 13:27:23 -0000 Delivered-To: apmail-logging-log4net-dev-archive@logging.apache.org Received: (qmail 29139 invoked by uid 500); 7 Feb 2009 13:27:23 -0000 Mailing-List: contact log4net-dev-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Log4NET Dev" List-Id: Delivered-To: mailing list log4net-dev@logging.apache.org Received: (qmail 29130 invoked by uid 99); 7 Feb 2009 13:27:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Feb 2009 05:27:23 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Feb 2009 13:27:21 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id A48B3234C4AB for ; Sat, 7 Feb 2009 05:26:59 -0800 (PST) Message-ID: <1240225075.1234013219672.JavaMail.jira@brutus> Date: Sat, 7 Feb 2009 05:26:59 -0800 (PST) From: "Ashish Khandelwal (JIRA)" To: log4net-dev@logging.apache.org Subject: [jira] Issue Comment Edited: (LOG4NET-195) Log4Net Performance comparison with other logging utility In-Reply-To: <412487638.1233727199554.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LOG4NET-195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12671461#action_12671461 ] jolonm edited comment on LOG4NET-195 at 2/7/09 5:25 AM: ------------------------------------------------------------------- I just updated the code to put Log4Net call on separate Thread, this rapidly improved the performance. Almost equivalent to the nSpring (some times better than nSpring) Explanation about the code: When user sends a message to log, I added sent log into the array list instead of sending this message directly to log4net. This increases the response time. Another method "Write" is running on separate thread which always looks to the array list and sends the message to the log4net to write. (Obviously there is changes to optimize the code which can further improve the performance, but overall design would be same). It looks like a better way to improve the response time. Let me know your view and if you find any other way(s) as well: static bool blnStop = false; static Thread t = null; static ApplicationLog() { t = new Thread(Write); t.Priority = ThreadPriority.BelowNormal; //t.Start(); } static ArrayList arlLogs = new ArrayList(); /// /// Log Debug /// /// Message to be logged /// Method Name(Location) public static void WriteDebug(string message, string methodName) { arlLogs.Add(methodName + " " + message); blnStop = false; if (!t.IsAlive) t.Start(); } private static void Write() { while (!blnStop) { if (log.IsDebugEnabled) { if (arlLogs.Count > 0) { log.Info(arlLogs[0]); arlLogs.RemoveAt(0); if (arlLogs.Count == 0) blnStop = true; } } } } was (Author: jolonm): I just updated the code to put Log4Net call on separate Thread, this rapidly improved the performance. Almost equivalent to the nSpring (some times better than nSpring) Explanation about the code: When user sends a message to log, I added sent log into the array list instead of sending this message directly to log4net. This increases the response time. Another method "Write" is running on separate thread which always looks to the array list and sends the message to the log4net to write. It looks like a better way to improve the response time. Let me know your view and if you find any other way(s) as well: static bool blnStop = false; static ApplicationLog() { Thread t = new Thread(Write); t.Priority = ThreadPriority.BelowNormal; t.Start(); } static ArrayList arlLogs = new ArrayList(); /// /// Log Debug /// /// Message to be logged /// Method Name(Location) public static void WriteDebug(string message, string methodName) { arlLogs.Add(methodName + " " + message); } private static void Write() { while (!blnStop) { if (log.IsDebugEnabled) { if (arlLogs.Count > 0) { log.Info(arlLogs[0]); arlLogs.RemoveAt(0); } } } > Log4Net Performance comparison with other logging utility > --------------------------------------------------------- > > Key: LOG4NET-195 > URL: https://issues.apache.org/jira/browse/LOG4NET-195 > Project: Log4net > Issue Type: Test > Affects Versions: 1.2.10 > Environment: .Net Framework 2.0, VS 2005, Windows XP > Reporter: Ashish Khandelwal > Priority: Critical > Attachments: Log4Net_Vs_nSpring.zip > > > I developed one utility to compare the performance between Log4Net and nSpring(another logging utility). The result I saw is surprise to me - Log4Net took more time than nSpring. It is surprise because "Log4net claims to be fast and flexible: speed first, flexibility second." > Log4Net says: (http://logging.apache.org/log4net/release/manual/internals.html) > One of the often-cited arguments against logging is its computational cost. This is a legitimate concern as even moderately sized applications can generate thousands of log requests. Much effort was spent measuring and tweaking logging performance. Log4net claims to be fast and flexible: speed first, flexibility second. > Although test is saying Log4Net takes more time, I am still not convinced with the result achieved, considering the fact; Log4Net is widely accepted by the industry and known for its speed, reliability and flexibility. > I would like to know why Log4Net is taking more time, we might be missing any setting or other which can boost the performance. Can you please help to know the reason? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.