I will like to try the second approach   , my log4j is initialized   by 
spring , I have 

<listener>
        
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>


in my web.xml.

Please tell me where should I  call System.setProperty("HOSTNAME",
InetAddress.getLocalHost
().getCanonicalHostName());

do I also have to  call  
DOMConfigurator.configure(getClass().getClassLoader().getResource(
"log4j.xml")); ?



Zbynek Vavros wrote:
> 
> 
> 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.:
> 
> 
> Then you got the hostname IP in email subject.
> 
> Cheers, Zbynek
>                                                                        
>  Kind Regards / Mit                                                    
>  freundlichen Grüßen /                                             
>  Üdvözlettel / S                                                   
>  pozdravem:                                                            
>                                                                        
>                                                                        
>  Zbynek VAVROS                                                 (Embedded
>  Development                                                 image moved
>                                                                 to file:
>                                                            pic44576.gif)
>                                                                        
>      Delivery Centre      616 00, Brno                                 
>       Central Europe      Technicka 21                                 
>         Brno SITE         Czech Republic                               
>                                                                        
>  (Embedded image moved to                                              
>    file: pic46945.gif)    Phone: 420-53341- x6283                      
>                           Mobile:                                      
>                           E-mail: [email protected]             
>                                                                        
>                                                                        
>                                                                        
>                                                                        
>    IBM Global Services                                                 
>   Delivery Center Czech                                                
>      Republic, s.r.o.                                                  
>    Registered address:                                                 
>  Brno, Technicka 2995/21,                                              
>  Zip code: 61600, Company                                              
>        ID: 26244535                                                    
>       Entered in the                                                   
>    Commercial Register                                                 
>     maintained by the                                                  
>   Regional Court in Brno                                               
>   (Part C, Entry 39922)                                                
>                                                                        
>    IBM Global Services                                                 
>   Delivery Center Czech                                                
>      Republic, s.r.o.                                                  
>   Sídlo: Brno, Technická                                           
>   2995/21, PSČ 61600 IČ:                                           
>          26244535                                                      
>    Zapsaná v obchodním                                             
>     rejstříku, vedeném                                           
>   Krajským soudem v Brně                                           
>   oddíl C, vlozka 39922                                              
>                                                                        
> 
> 
> 
> 
> 
> 
> From: fachhoch <[email protected]>
> To:   [email protected]
> Date: 11/16/2011 04:29 PM
> Subject:      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 <[email protected]> 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.
>>>
>>>
>>>
>>>
>>> --
>>> 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.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>> --
>> Sent from my mobile device
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
> 
> --
> View this message in context:
> http://old.nabble.com/SMTPAppender-%2C-server-instance-tp32850377p32855452.html
> 
> Sent from the Log4j - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 

-- 
View this message in context: 
http://old.nabble.com/SMTPAppender-%2C-server-instance-tp32850377p32856095.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to