sangeetha k | 1 Nov 2011 17:04
Picon
Favicon

chainsaw issue

Hi,
 
I am using chainsaw to view the log generated using log4j.
 
Here is my configurations
 
Sample log
 
2011-10-31 08:02:00,332 [ INFO] [9447566 <at> qtp-19458313-0]
[net.hp.tr.businesslogic.referenceimplcustomer.businesslogic.CustomerController]
[Organization: Travelocity] [Client: AA] [Location of device: DFW] [User: 550393] [User_role:
Provider] [CorelationId: 947] [URL :
http://localhost:8080/webapp/app/common_ux_js_shell/shell_devel.html] [Component:
CustomerController.get] [Server: 127.0.0.1] [Request: ] [Response: void] [Status: pass] - Entering
Method = get() 
 
log4j format
 <layoutclass="org.apache.log4j.PatternLayout"><!-- The log message pattern
--><paramname="ConversionPattern"value="%d{ISO8601} [%p] [%t] [%X{classname}] [Organization:
%X{organization}] [Client: %X{client}] [Location of device: %X{deviceloc}] [User: %X{user}]
[User_role: %X{user_role}] [CorelationId: %X{corelationID}] [URL : %X{url}] [Component:
%X{component}] [Server: %X{server}] [Request: %X{request}] [Response: %X{response}] [Status:
%X{status}] - %m%n"/></layout>
 
chainsaw configuration
 
<param name="logFormat" value="TIMESTAMP [LEVEL] [THREAD] [CLASS] [PROP(ORGAN)] [PROP(CLIENT)]
[PROP(LOCATION_DEVICE)] [PROP(USER)] [PROP(ROLE)] [PROP(CORELATIONID)] [PROP(URL)]
[PROP(COMPONENT)] [PROP(SERV)]  * - MESSAGE"/>
 
(Continue reading)

Steve Cohen | 2 Nov 2011 04:04

org.apache.log4j.MDC vs. org.slf4j.MDC

I haven't used MDC's in awhile but today I thought I saw a way to put 
them to advantage for an application I'm working on.  In doing so, 
though ,I stumbled upon an incompatibility between log4j's MDC and 
slf4j's MDC that I've not seen much comment on.

The signatures for the get() and put() methods in the two MDC classes 
are incompatible.

In log4j, it's

public static Object get(String key)

and

public static void put(String key,
                        Object o)
while in slf4j (and logback), it's

public static String get(String key)
                 throws IllegalArgumentException
and

public static void put(String key,
                        String val)
                 throws IllegalArgumentException

I'm not concerned about the exceptions as much as I am about the 
restriction to Strings.

It so happens that the use case I came up with today much prefers 
(Continue reading)

Jacob Kjome | 2 Nov 2011 16:31
Favicon

Re: org.apache.log4j.MDC vs. org.slf4j.MDC


Hi Steve,

Your question really should be directed to the SLF4J mailing list [1], as 
Log4j already provides what you need.  Your question deals with "why doesn't 
SLF4J provide what Log4j provides", which the Log4j team cannot 
authoritatively answer.

[1] http://slf4j.org/mailing-lists.html

Jake

On Tue, 01 Nov 2011 22:04:24 -0500
 Steve Cohen <scohen <at> javactivity.org> wrote:
> I haven't used MDC's in awhile but today I thought I saw a way to put them 
>to advantage for an application I'm working on.  In doing so, though ,I 
>stumbled upon an incompatibility between log4j's MDC and slf4j's MDC that 
>I've not seen much comment on.
> 
> The signatures for the get() and put() methods in the two MDC classes are 
>incompatible.
> 
> In log4j, it's
> 
> public static Object get(String key)
> 
> and
> 
> public static void put(String key,
>                        Object o)
(Continue reading)

ceki | 2 Nov 2011 17:45
Picon
Gravatar

Re: org.apache.log4j.MDC vs. org.slf4j.MDC

On 02.11.2011 04:04, Steve Cohen wrote:

 > But why was the ability to store non-Strings [in MDC] removed
 > between log4j and slf4j in the first place?

Since java Strings are immutable, once inserted into the MDC, values
cannot be changed (voluntarily or otherwise). This makes SLF4J-style
MDC more predictable and less error prone. Of course, SLF4J's the
stricter MDC interface allows less flexibility.
--
Ceki
http://twitter.com/#!/ceki
Ganesh_912 | 8 Nov 2011 13:29
Picon

Not able to create log file FileAppender


Hi ,

I am designing a web app which will create log files dyanamically from a
servlet when app is deployed but it is creating a log file from .properties
file only.

Below is servlet code snippet that i am using to create a log file with
log4j.properties file.

public void contextInitialized(ServletContextEvent sce) {
        try {

         // Load log4j.properties from WEB-INF folder
         String log4jConfigurationFile =
sce.getServletContext().getRealPath("/WEB-INF/log4j.properties");         
         PropertyConfigurator.configure(log4jConfigurationFile);

         //Override log4j Configuration
         String newLogFilePath = "C:/tempTEST/hi/Test_Logger1.log"; // Get
this path from environment variable dynamically

          if(newLogFilePath !=null) {
              Appender oldFileAppender =
Logger.getRootLogger().getAppender("FILE"); // Existing Appender
              	

              //PatternLayout pattern = new PatternLayout("%m%n"); // create
a new pattern if required
              FileAppender newFileAppender = new FileAppender ();
(Continue reading)

Stadelmann Josef | 9 Nov 2011 09:44
Picon

AW: Not able to create log file FileAppender


    private Logger clog = null;              // keeps the configured-logger

    private Logger slog = null;              // keeps the session-logger

    private Logger log  = null;              // keeps the local copy of the session-logger

    private String NameOfLogger = null;      // keeps the session oriented NameOfLogger

    private FileAppender sfapp = null;       // keeps the session file appender simply for close()

    private SocketHubAppender ssapp = null;  // the socket appender to send log events to Chanisaw

    private int i = -1;                         // -1

    private Integer intObj = new Integer(i);    // -1

    // get the instance date-time (get time-stamp when this web-service is born)

    // get the time/date when the object of class SpTestServer is created

    private String oDate = new Date().toString();

    public void init(ServiceContext sCtx) throws XMLStreamException, WsiException {

        try {

         System.out.println(OperatingSystem);

         String scID = SpServer.class.getName().toString();
(Continue reading)

fachhoch | 15 Nov 2011 21:47
Picon

SMTPAppender , server instance


I am want to use   org.apache.log4j.net.SMTPAppender , can this appender
append the system name   when sending email ?

Our code will be deployed to production , staging , training , development
instance.    
SMTPAppender    send out email but I cannot tell if this exception happened
in production, staging,development , training environment, any suggestions? 
I  prefer not to change code for each   instance deployment.

--

-- 
View this message in context: http://old.nabble.com/SMTPAppender-%2C-server-instance-tp32850377p32850377.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
Brett Randall | 15 Nov 2011 22:53
Picon

Re: SMTPAppender , server instance

Could you configure this with the Subject param?

From log4j wiki:

<appender
name="AdministratorEmail"
class="org.apache.log4j.net.
SMTPAppender">
...
<param name="Subject"
value="SomeApplication on
SomeServer12" />

Brett

On 11/16/11, fachhoch <fachhoch <at> gmail.com> wrote:
>
> I am want to use   org.apache.log4j.net.SMTPAppender , can this appender
> append the system name   when sending email ?
>
> Our code will be deployed to production , staging , training , development
> instance.
> SMTPAppender    send out email but I cannot tell if this exception happened
> in production, staging,development , training environment, any suggestions?
> I  prefer not to change code for each   instance deployment.
>
>
>
>
> --
(Continue reading)

fachhoch | 16 Nov 2011 16:28
Picon

Re: SMTPAppender , server instance


Thanks for your reply, 
If I  use param then I have  to send different deployments to different
servers whihc I dont want .  Can I  plugin some code  which appends the
system name  (I mean host name of the machine )to the value of the param ?

javabrett wrote:
> 
> Could you configure this with the Subject param?
> 
> From log4j wiki:
> 
> <appender
> name="AdministratorEmail"
> class="org.apache.log4j.net.
> SMTPAppender">
> ...
> 
> 
> Brett
> 
> On 11/16/11, fachhoch <fachhoch <at> gmail.com> wrote:
>>
>> I am want to use   org.apache.log4j.net.SMTPAppender , can this appender
>> append the system name   when sending email ?
>>
>> Our code will be deployed to production , staging , training ,
>> development
>> instance.
>> SMTPAppender    send out email but I cannot tell if this exception
(Continue reading)

Zbynek Vavros | 16 Nov 2011 16:38
Picon
Favicon

Re: SMTPAppender , server instance


Hi,

you can use profiling for deployment - Maven is excellent for that.
You would deploy different packages but to create them is extremely easy.

Or you could use method I was using before Maven but its not so "clean":

1 - at the beggining of your code set a system property:
System.setProperty("HOSTNAME", InetAddress.getLocalHost
().getCanonicalHostName());

2 - force log4j to configure again with something like:
DOMConfigurator.configure(getClass().getClassLoader().getResource(
"log4j.xml"));

3 - use this property in your log4j configration, i.e.:
<param name="Subject" value="Error from ${HOSTNAME}" />

Then you got the hostname IP in email subject.

Cheers, Zbynek

 Kind Regards / Mit                                                      
 freundlichen Grüßen /                                                   
 Üdvözlettel / S                                                         
 pozdravem:                                                              

                                                                         
 Zbynek VAVROS                                                 (Embedded 
(Continue reading)


Gmane