improvements and questions.

"kRAkEn/gORe" <[email protected]> Tue, 14 Oct 2008 09:09:43 +0200
Newsgroups gmane.comp.java.helma.general
Message-ID <[email protected]>
--===============1263266662==
Content-Type: multipart/alternative; 
	boundary="----=_Part_1463_26005808.1223968183523"

------=_Part_1463_26005808.1223968183523
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi i've come into a series of problems with logging so far when mixing helma
and
other libraries around (especially the apache commons). For example i'm
using FOP
all the time for render PDF reports, and if you use FOP in debug mode there
are chances to
get StackOverflows here and there. So the only way to disable FOP debugging
in helma is to
modify the Logging LogFactory class this way.

keep track of a system (but better app.properties) variable that keeps which
kind of classes
you need to disable:

    Vector disabledLoggers = new Vector ();
    String disabledClasses = System.getProperty("helma.disablelog", "");

    String[] disabled = disabledClasses.split (":");
    for (int i = 0; i < disabled.length; i++)
    {
        String disableTempClass = disabled[i].trim();
        if (disableTempClass.length () > 0)
            disabledLoggers.add (disableTempClass);
    }

then in public Log getInstance(String logname) we do:

    // normalize log name
    logname = logname.replaceAll("[^\\w\\d\\.]", "");

    for (int i = 0; i < disabledLoggers.size(); i++)
        if (logname.startsWith ((String) disabledLoggers.get (i)))
            return getNoLog();

and getNoLog is like this:

    // static global to the class no logger
    static NoOpLog noLog = new NoOpLog ();

    /**
     * Get a no logger
     * @return a logger that writes to Nirvana
     */
    public static Log getNoLog() {
        return noLog;
    }

----------------------------------------------------------------------

Anyway while browsing the Logging code i see the line in constructor:

    logdir = System.getProperty("helma.logdir", "log");

After doing some debugging, "helma.logdir" is set when Server starts from
the server.properties logDir
property (if it isn't system wise), but actually server.properties is parsed
AFTER the Logging class have
been initialized. So for instance we can have dicrepancies between the
actual log directories and the
ones we have specified in the server.properties.


Let me know what u think

ps. Keep up the good work with HelmaNG !!!

Cheers,

Lucio

------=_Part_1463_26005808.1223968183523
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div dir="ltr">Hi i&#39;ve come into a series of problems with logging so far when mixing helma and<br>other libraries around (especially the apache commons). For example i&#39;m using FOP<br>all the time for render PDF reports, and if you use FOP in debug mode there are chances to<br>
get StackOverflows here and there. So the only way to disable FOP debugging in helma is to <br>modify the Logging LogFactory class this way.<br><br>keep track of a system (but better app.properties) variable that keeps which kind of classes<br>
you need to disable:<br><br>&nbsp;&nbsp;&nbsp; Vector disabledLoggers = new Vector ();<br>&nbsp;&nbsp;&nbsp; String disabledClasses = System.getProperty(&quot;helma.disablelog&quot;, &quot;&quot;);<br><br>&nbsp; &nbsp; String[] disabled = disabledClasses.split (&quot;:&quot;);<br>
&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; disabled.length; i++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String disableTempClass = disabled[i].trim();<br>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; if (disableTempClass.length () &gt; 0)<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; disabledLoggers.add (disableTempClass);<br>
&nbsp;&nbsp;&nbsp; }<br><br>then in public Log getInstance(String logname) we do:<br><br>&nbsp;&nbsp;&nbsp; // normalize log name<br>&nbsp;&nbsp;&nbsp; logname = logname.replaceAll(&quot;[^\\w\\d\\.]&quot;, &quot;&quot;);<br><br>&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; disabledLoggers.size(); i++)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (logname.startsWith ((String) disabledLoggers.get (i)))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return getNoLog();<br><br>and getNoLog is like this:<br><br>&nbsp;&nbsp;&nbsp; // static global to the class no logger<br>&nbsp;&nbsp;&nbsp; static NoOpLog noLog = new NoOpLog ();<br>
<br>&nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp;&nbsp; * Get a no logger<br>&nbsp;&nbsp;&nbsp;&nbsp; * @return a logger that writes to Nirvana<br>&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp; public static Log getNoLog() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return noLog;<br>&nbsp;&nbsp;&nbsp; }<br><br>----------------------------------------------------------------------<br>
<br>Anyway while browsing the Logging code i see the line in constructor:<br><br>&nbsp;&nbsp;&nbsp; logdir = System.getProperty(&quot;helma.logdir&quot;, &quot;log&quot;);<br><br>After doing some debugging, &quot;helma.logdir&quot; is set when Server starts from the server.properties logDir<br>
property (if it isn&#39;t system wise), but actually server.properties is parsed AFTER the Logging class have<br>been initialized. So for instance we can have dicrepancies between the actual log directories and the<br>ones we have specified in the server.properties.<br>
<br><br>Let me know what u think<br><br>ps. Keep up the good work with HelmaNG !!!<br><br>Cheers,<br><br>Lucio<br><br><br><br><br><br></div>

------=_Part_1463_26005808.1223968183523--

--===============1263266662==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Helma-user mailing list
[email protected]
http://helma.org/mailman/listinfo/helma-user

--===============1263266662==--