Need help in log4j configuration file


Web tier: servlets, JSP, Web frameworks: Need help in log4j configuration file

  1. Need help in log4j configuration file (3 messages)

    Hello guys,
      I am using log4j for my web tier log system and feedback. I have this appender

        <appender name="EMAIL" class="">
            <param name="BufferSize" value="1" />
            <param name="From" value="admin at commercehub dot com" />
            <param name="To" value="hpathak at commercehub dot com" />
            <param name="Subject" value="Feedback" />
            <param name="SMTPHost" value="" />
            <param name="LocationInfo" value="true" />
            <param name="EvaluatorClass" value="com.commercehub.log.CtiEmailEvaluator" />
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern"
                       value="%d %p (%F:%L) - %m%n"/>

    Now for the parameter "Subject" I want to change its value dynamically. Right now for emails I get subject line "Feedback". I want some dynamic value to add to subject line... so it will be "Feedback -- abcdzyx".

    Is that possible ?? Can I change its value dynamically ?

    Please somebody help me.. thanks.
  2. import com.commercehub.log.CtiEmailEvaluator;

          Logger _logger = Logger.getRootLogger();

          CtiEmailEvaluator _eval = new CtiEmailEvaluator();
          SMTPAppender _smtp = new SMTPAppender(_eval);
          _smtp.setFrom("admin at commercehub dot com");
          _smtp.setTo("hpathak at commercehub dot com");
          _smtp.setLayout(new SimpleLayout()); //here use your PatternLayout

  3. Or just:

          import com.commercehub.log.CtiEmailEvaluator;

          Logger _logger = Logger.getRootLogger();
          SMTPAppender _smtp =
              (SMTPAppender) _logger.getAppender("EMAIL");


  4. Its working great[ Go to top ]

    Thanks a lot.. Its working great.