RDX | 9 Feb 2012 14:57
Favicon

Re: Having trouble getting XMLSocketAppender to reconnect

Matthew Bingham <texbingham <at> gmail.com> writes:

> 
> I have been using XMLSocketAppender without much issue, except for when the 
connection is lost log4cxx is never reconnecting.  I have ReconnectionDelay 
set to 1000 and when the connection goes I see log4cxx display "log4cxx: 
Detected problem with connection: log4cxx: IO Exception : status code = 
730053"  This is with a 64 bit build with VS2008.  I configure log4cxx from an 
xml file and in the the source just calllogger_ = Logger::getLogger
("Server");LOG4CXX_DEBUG(logger_,"Server logging");      Any suggestions?  
Below is the log4cxx debug information.  Thanks.  log4cxx: Threshold ="".
> log4cxx: Level value for root is [all].log4cxx: OptionConverter::toLevel: no 
class name specified, level=[all]log4cxx: root level set to ALLlog4cxx: 
Retreiving an instance of Logger.log4cxx: Setting [Server] additivity to 
[true].
> log4cxx: Level value for Server is [debug].log4cxx: 
OptionConverter::toLevel: no class name specified, level=[debug]log4cxx: 
Server level set to DEBUGlog4cxx: Class name: 
[org.apache.log4j.net.XMLSocketAppender]
> log4cxx: Setting option name=[Port], value=[12345]log4cxx: Setting option 
name=[RemoteHost], value=[192.168.1.102]log4cxx: Setting option name=
[ReconnectionDelay], value=[1000]log4cxx: Setting option name=[LocationInfo], 
value=[true]
> log4cxx: Parsing layout of class: "org.apache.log4j.PatternLayout"log4cxx: 
Setting option name=[ConversionPattern], value=[%d %-5p [%c] %m%n]log4cxx: 
Adding appender named [MyXmlAppenderFormated] to logger [Server].
> log4cxx: Retreiving an instance of Logger.log4cxx: Setting 
[multicastListener] additivity to [true].log4cxx: Level value for 
multicastListener is [warn].log4cxx: OptionConverter::toLevel: no class name 
specified, level=[warn]
(Continue reading)

drkmkzs | 22 Feb 2012 16:55
Picon

Concurrent access

Hi, 

I'm currently using Log4Cxx in a C++ application, with a log file property. Now i have to launch several instances of this program, which means several processes will used the same log property file, and therefore the same log file...

I guess it is not handled by log4cxx ? I know it's thread safe, but for concurrent access in the same main application (like thread or fork), not between different applications ? 

And i imagine a better approach would be to configure log4cxx within the code (instead property file) in order to change log file name for each processess ?

Thanks in advance, 
sorry for my english
Jean
Chhavi Agarwal | 22 Feb 2012 17:31
Picon

AUTO: Chhavi Agarwal is out of the office (returning 02/27/2012)


I am out of the office until 02/27/2012.

On Vacation.
Please contact Imran.kazi <at> in.ibm.com ( Imranuddin W Kazi )l for any project
related queries.
If urgent call me 9740335000

Note: This is an automated response to your message  "Concurrent access"
sent on 22/2/12 21:25:40.

This is the only notification you will receive while this person is away.

Thorsten Schöning | 23 Feb 2012 09:34
Picon

Re: Concurrent access

Guten Tag drkmkzs,
am Mittwoch, 22. Februar 2012 um 16:55 schrieben Sie:

> And i imagine a better approach would be to configure log4cxx within the
> code (instead property file) in order to change log file name for each
> processess ?

Not necessarily. I don't know if log4cxx properly handles concurrent
access to the same file on a per process basis, but I personally
dislike configuring log4cxx in code and in your case it wouldn't be
necessary, depending on what your really try to achieve with your log
files. If it's just about to separate the log files of more than one
instance of your program, one approach could be to provide a unique
environment variable in your program on per instance basis before
configuring log4cxx with its property or xml file, because log4cxx is
able to use environment variable in the configuration at least in
paths. I use that to distinct two calls of the same program by
different callers where the callers provide an id of who they are and
that id is set as an environment variable and used in the log
configuration as part of the path to the log file. This ID can be
whatever you like, process id, GUID, something from the caller, it all
depends on what you do with the logs.

The syntax to get something from the environment is ${something}, like
in the following example:

<appender       name="Dbxml.monthSpecificLogFile"
                class="org.apache.log4j.rolling.RollingFileAppender">
        <rollingPolicy  class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
                <param  name="FileNamePattern"
                        value="..\..\..\Datenserver\Logdateien\dbxml\dbxml\${mandant}\%d{yyyy-MM}.log"
                />
        </rollingPolicy>
        <layout class="org.apache.log4j.PatternLayout">
                <param  name="ConversionPattern"
                        value="%d{yyyy-MM-dd HH:mm:ss,SSS} %p> %c.%M: %m%n"
                />
        </layout>
        <param  name="append"
                value="true"
        />
</appender>

Mit freundlichen Grüßen,

Thorsten Schöning

--

-- 
Thorsten Schöning       E-Mail:Thorsten.Schoening <at> AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon.............030-2 1001-310
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hanover HRB 207 694 - Geschäftsführer: Andreas Muchow

drkmkzs | 23 Feb 2012 13:02
Picon

Re: Concurrent access

Hey ! 

This is a really helpfull answer, that's exactly what I wanted, because like you I don't really like to put log configuration within the code :)  

I'm looking forward to use it ;)  
I'll try later to determine Log4cxx behaviour with 2 applic, just to know, it's still an intersting question...

Thanks a lot Thorsten !

2012/2/23 Thorsten Schöning <tschoening <at> am-soft.de>
Guten Tag drkmkzs,
am Mittwoch, 22. Februar 2012 um 16:55 schrieben Sie:

> And i imagine a better approach would be to configure log4cxx within the
> code (instead property file) in order to change log file name for each
> processess ?

Not necessarily. I don't know if log4cxx properly handles concurrent
access to the same file on a per process basis, but I personally
dislike configuring log4cxx in code and in your case it wouldn't be
necessary, depending on what your really try to achieve with your log
files. If it's just about to separate the log files of more than one
instance of your program, one approach could be to provide a unique
environment variable in your program on per instance basis before
configuring log4cxx with its property or xml file, because log4cxx is
able to use environment variable in the configuration at least in
paths. I use that to distinct two calls of the same program by
different callers where the callers provide an id of who they are and
that id is set as an environment variable and used in the log
configuration as part of the path to the log file. This ID can be
whatever you like, process id, GUID, something from the caller, it all
depends on what you do with the logs.

The syntax to get something from the environment is ${something}, like
in the following example:

<appender       name="Dbxml.monthSpecificLogFile"
               class="org.apache.log4j.rolling.RollingFileAppender">
       <rollingPolicy  class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
               <param  name="FileNamePattern"
                       value="..\..\..\Datenserver\Logdateien\dbxml\dbxml\${mandant}\%d{yyyy-MM}.log"
               />
       </rollingPolicy>
       <layout class="org.apache.log4j.PatternLayout">
               <param  name="ConversionPattern"
                       value="%d{yyyy-MM-dd HH:mm:ss,SSS} %p> %c.%M: %m%n"
               />
       </layout>
       <param  name="append"
               value="true"
       />
</appender>

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning       E-Mail:Thorsten.Schoening <at> AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon.............030-2 1001-310
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hanover HRB 207 694 - Geschäftsführer: Andreas Muchow


chand priyankara | 28 Feb 2012 03:45
Favicon

RE: Valgrind memory issue

Hi Norman, Thorsten Schöning 

I was working with vc++ in windows and memory leaks seems to be happen when debug version of .lib was using in release builds and vice versa.
If correct files were used there is no issue. i used _CRTDBG_MAP_ALLOC to check memory issues in VC++. 

--

  
Chand Priyankara 
|(094) 773-361566 
|chand <at> engineering.com
|www.blog.friendly.com
   



Gmane