Return-Path: X-Original-To: apmail-logging-log4net-dev-archive@www.apache.org Delivered-To: apmail-logging-log4net-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 88B1BD301 for ; Wed, 3 Oct 2012 12:07:50 +0000 (UTC) Received: (qmail 98663 invoked by uid 500); 3 Oct 2012 12:07:50 -0000 Delivered-To: apmail-logging-log4net-dev-archive@logging.apache.org Received: (qmail 98433 invoked by uid 500); 3 Oct 2012 12:07:46 -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 98411 invoked by uid 99); 3 Oct 2012 12:07:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2012 12:07:45 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dpsenner@gmail.com designates 74.125.83.47 as permitted sender) Received: from [74.125.83.47] (HELO mail-ee0-f47.google.com) (74.125.83.47) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2012 12:07:37 +0000 Received: by eeit10 with SMTP id t10so3780332eei.34 for ; Wed, 03 Oct 2012 05:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:references:in-reply-to:subject:date:message-id:mime-version :content-type:content-transfer-encoding:x-mailer:thread-index :x-ms-exchange-organization-originalclientipaddress :x-ms-exchange-organization-originalserveripaddress:x-mimeole; bh=D1jgQ0tWN2o7I3bgxdQoWqpFPjZiSM8nL9XYHKUCB88=; b=Xyrc/xfuybcwAGtT/O6pAtA3xDWtGOsucsaqpRTTR42fV1XgOTvN+DIxYB0EIIEcEK 7H6Ma82ewUgxIAwnGCzDbKGv3qfqaYfdbpQfucCX96mEakyurAyp3oI5Be0W7Anfmxg0 ALhgpmJ3HSMwN2Q0XzYelfZ01LrtRaAgsEWotpHm0zCw4NXNSt7GAuKkn3QXVrQHQGeu 1D5C2aZD72ggmHAj8/LjUSWrJyjReh2b9nqhVGNyz5m6/eQWQXNHhTT9D99u+qpoh1xH xd9ix2jxgDfuuEzSdgnvxZ/GgbItGXQ1TKh46vbfJrvjeyUwO+FtQp7OdMecKEBH/5Ti a7iQ== Received: by 10.14.200.134 with SMTP id z6mr2301294een.33.1349266036516; Wed, 03 Oct 2012 05:07:16 -0700 (PDT) Received: from DOMINIKP ([95.171.44.200]) by mx.google.com with ESMTPS id g5sm9522640eem.4.2012.10.03.05.07.08 (version=SSLv3 cipher=OTHER); Wed, 03 Oct 2012 05:07:16 -0700 (PDT) From: "Dominik Psenner" To: "'Log4NET Dev'" References: <34508400.post@talk.nabble.com> <34508605.post@talk.nabble.com> In-Reply-To: <34508605.post@talk.nabble.com> Subject: RE: Object Reference issue in changing the Log file name dynamically in threads Date: Wed, 3 Oct 2012 14:06:53 +0200 Message-ID: <992368533831410DB77AF537D4EE5965@alpin.local> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: Ac2hWMizG5TZVTp+QF6pwJtG9mrBQQAAcB6g x-ms-exchange-organization-originalclientipaddress: 192.168.25.115 x-ms-exchange-organization-originalserveripaddress: fe80::dbc:9157:39b:6c99%12 X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7601.17609 X-Virus-Checked: Checked by ClamAV on apache.org >This Works fine Glad to hear that. >.. i am unable to use static appenders. Because i need to >change the name of the log file based on my processing function in my >application. I can understand your problem. Unfortunately there is no easy way to change the logfile dynamically at runtime. It all comes down to spawning and disposal of file appenders at runtime. >Now my problem is am unable to use httpcontext or session >objects in threads.. Is there any way to do this? Log4net does not imply rules on the scope of httpcontext or session variables in threads. Thus this does not seem to be a log4net problem at all. If I did not understand what you were saying here, please rephrase the question. >Or else how can i creating log files dynamically? In my opinion there's no safe way to do that. But someone elses mileage may vary. A logfile is equivalent to a single (rolling) file appender and a single (rolling) file appender can only append log events into exactly one logfile. If you somehow manage to change that logfile at runtime it will affect all other log events that should be written by this (rolling) file appender too. Whether or not they come from another thread doesn't matter. Generally said, the "logic" of dispatching messages should be placed into event filters that are assigned to an appender. You could create a hierarchy of remoting appenders that finally sink log events into a rolling file appender, but in my humble opinion this construct is far to complex for a mere logger. The worst logger you can have is one that does not log at all because it was designed too complicated. Therefore I encourage you to log events into a database. Then you can fetch log events from that database with all different fancy logic you need. Cheers, D.