logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Malte.Kem...@de.equens.com>
Subject Communcating An Own Properties-Object To log4j As Substtution For System-Properties
Date Fri, 16 Nov 2012 14:12:18 GMT
 Hi to all (again),
I just thought on theoretical level. My problem, using log4j in a mulithraded environment
using
Apender that create file names using property input could only work, if it is possible to
give the appender (log4)
An own properties-object, rahter than using the Systm-Properties.
Is there a method, with that you are able to tell an apender to get an very own Properties-Object
with out the need to change the configuration possibility using ${propertiesname} to address
the partcular property?

right now my appender configuration looks liek that:

<appender name="xsd-check" class="de.cmk.log4j.NameComposingFileAppender"> 
        <param name="string4Construction" value="${input.file.path}"></param>
       
        <param name="inputRegex" value="(.*)"></param>
        <param name="file" value="logs/[user.name]/XSDCHECK.(0).log" ></param>

        <param name="Append" value="false" /> 
        <layout class="org.apache.log4j.PatternLayout"> 
                <param name="ConversionPattern" 
                      value="%d{ISO8601} %-5p %m%n" /> 
        </layout> 
</appender>

I would like to tell the an appender, by using a log4j-method within a certian application
init-time.

Is there something like that or is something like that planned in a later version of log4j?
(Is there any chance something like that would work at all?)

thanks in advancs for any hints

 
Malte



-----Urspr√ľngliche Nachricht-----
Von: Malte.Kempff@de.equens.com [mailto:Malte.Kempff@de.equens.com <mailto:Malte.Kempff@de.equens.com>
]
Gesendet: Freitag, 16. November 2012 13:37
An: log4j-user@logging.apache.org
Betreff: AW: Funny Bbehaviour Wth A Customzed Appender

Hi Gary,
finally I found the trouble. It got nothing to do with log4j itself. It is the stuff around
my application, since I comuniate the input file names within Systemproperties, that are filled
by one but not by the other application. The logger produces empty files for each, even though
the other application not even running.  I guess the cause of this is that I am using just
one logging config for all my applcations. I probably could fix this behaviour by using for
each application an own logger config.

Inkow, using system properties is not the best choice, because they are global. That makes
thread safety impossible. For a long term I should overthink the comunication of properties
to my NamedFileAppender.
Is there another way to build up a file name for the logging using things like input file
names may be with appenders that are shiiped with log4j?

Malte

________________________________

Von: Gary Gregory [mailto:garydgregory@gmail.com <mailto:garydgregory@gmail.com> ]
Gesendet: Donnerstag, 15. November 2012 18:03
An: Log4J Users List
Betreff: Re: Funny Bbehaviour Wth A Customzed Appender


Hi Malte,

You should probably file a Bugzilla issue but I am not sure how much
help you'll get here because you are using custom code. There you can
attach all the files you want.

Can this be reproduced in any way with a stock appender of any type like
a rolling file appender?

The best way to get anyone to help is to create a standalone program
that illustrates the problem. Ideally, it should be a unit test that
fails.

Another question that will come up is, does using the current version,
1.2.17, work better? Differently?

Gary


On Thu, Nov 15, 2012 at 11:14 AM, <Malte.Kempff@de.equens.com> wrote:


       
        Hi to all,
        I have programmed an appender dirived from FileAppender, that is
able to produce log-files with file names that you can controll in a
more flexible way.
        You can use an other String, for example the input file,  or
parts of it to produce your desired log file name, seq-numbers and time
stamps etc.
        
        My applcation, that got the log-config (actually the xml
configuration type) is a mroe infratstuctional Programm, that calls
other applications like converters.
        I have put all in one single log-configuration-file using the
cusomized appender on several file processing applcations.
        
        The confguration  is like this, that each processed file is
suppose to produce one log file per application that is processing it.
        
        For one application it works pretty good. Ror another it
produces each expected log file but produces the logs for all turns only
in one file. The others stay empty.
        
        
        
        I am not sure what I am doing wrong and what is going on here. I
cannot understand why in one case it works (s.FEDCONV...log) , in the
other it does not at all (s. XSDCHECK...log).
        
        here the contend of the only filled XSDCHECK...log
(XSDCHECK.x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.120001.000.TXT.log)
        2012-11-15 09:33:52,594 INFO
*****************************************
        2012-11-15 09:33:52,594 INFO  * XSD-Checker  V 1.0
*
        2012-11-15 09:33:52,594 INFO
*****************************************
        2012-11-15 09:33:52,610 INFO  using 'C:\tmp\Neuer
Ordner\FED-Local\filedemon-fed-test\xsds\pacs.008.001.01.xsd' as
XSD-File
        2012-11-15 09:33:52,610 INFO  using
'xsdError\x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.120002.000.TXT.pacs08.xm
l' as Input-File
        2012-11-15 09:33:52,672 INFO
"xsdError\x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.120002.000.TXT.pacs08.xm
l" is valid.
        2012-11-15 09:33:52,688 INFO
*****************************************
        2012-11-15 09:33:52,688 INFO  * XSD-Checker  V 1.0
*
        2012-11-15 09:33:52,688 INFO
*****************************************
        2012-11-15 09:33:52,688 INFO  using 'C:\tmp\Neuer
Ordner\FED-Local\filedemon-fed-test\xsds\pacs.008.001.01.xsd' as
XSD-File
        2012-11-15 09:33:52,688 INFO  using
'xsdError\x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.090004.000.TXT.pacs08.xm
l' as Input-File
        2012-11-15 09:33:52,719 INFO
"xsdError\x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.090004.000.TXT.pacs08.xm
l" is valid.
        2012-11-15 09:33:52,719 INFO
*****************************************
        2012-11-15 09:33:52,719 INFO  * XSD-Checker  V 1.0
*
        2012-11-15 09:33:52,735 INFO
*****************************************
        2012-11-15 09:33:52,735 INFO  using 'C:\tmp\Neuer
Ordner\FED-Local\filedemon-fed-test\xsds\pacs.008.001.01.xsd' as
XSD-File
        2012-11-15 09:33:52,735 INFO  using
'xsdError\x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.090005.000.TXT.pacs08.xm
l' as Input-File
        2012-11-15 09:33:52,750 INFO
"xsdError\x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.090005.000.TXT.pacs08.xm
l" is valid.
        2012-11-15 09:33:52,750 INFO
*****************************************
        2012-11-15 09:33:52,766 INFO  * XSD-Checker  V 1.0
*
        2012-11-15 09:33:52,766 INFO
*****************************************
        2012-11-15 09:33:52,766 INFO  using 'C:\tmp\Neuer
Ordner\FED-Local\filedemon-fed-test\xsds\pacs.008.001.01.xsd' as
XSD-File
        2012-11-15 09:33:52,766 INFO  using
'xsdError\x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.090006.000.TXT.pacs08.xm
l' as Input-File
        2012-11-15 09:33:52,781 INFO
"xsdError\x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.090006.000.TXT.pacs08.xm
l" is valid.
        2012-11-15 09:33:52,781 INFO
*****************************************
        2012-11-15 09:33:52,781 INFO  * XSD-Checker  V 1.0
*
        2012-11-15 09:33:52,797 INFO
*****************************************
        2012-11-15 09:33:52,797 INFO  using 'C:\tmp\Neuer
Ordner\FED-Local\filedemon-fed-test\xsds\pacs.008.001.01.xsd' as
XSD-File
        2012-11-15 09:33:52,797 INFO  using
'xsdError\x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.120001.000.TXT.pacs08.xm
l' as Input-File
        2012-11-15 09:33:52,813 INFO
"xsdError\x.C0100.MCP.SAG.SWIFT-MAX.AC.20121106.120001.000.TXT.pacs08.xm
l" is valid.
        
       
        here the content was filled obviously in the log-file of the
last File beeing processed, instead of puting them to each log, that has
already been produced.
        
        Please find attached the source code of the appender and
dependings  (*.java) , the configuration(log4j.xml), and an example of
the logging of log4j itself (log4j-log-log).
        I am using log4j version log4j-1.2.15.jar
        
       
        Best regards and thanks for any hints in advance

        Malte



       
---------------------------------------------------------------------
        To unsubscribe, e-mail:
log4j-user-unsubscribe@logging.apache.org
        For additional commands, e-mail:
log4j-user-help@logging.apache.org
       




--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977 <http://goog_1249600977> > http://bit.ly/ECvg0
<http://bit.ly/ECvg0> 
Spring Batch in Action: <http://s.apache.org/HOq <http://s.apache.org/HOq> > http://bit.ly/bqpbCK
<http://bit.ly/bqpbCK> 
Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com> 
<http://garygregory.wordpress.com/ <http://garygregory.wordpress.com/> > 
Home: http://garygregory.com/ <http://garygregory.com/> 
Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory> 




Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message