goetz | 1 Apr 2002 21:35

Feature request: short names for Level/Priority classes

Hi

I would like to see short names in the Level class (as I proposed already
earlier this year). A single character entry would do.

Here some code snippets to realize it:

...

public class Priority {

  int level;
  String levelStr;
  String shortLevelStr;

...

  /**
     Returns the short string representation of this priority.
   */
  final
  public
  String toShortString() {
    return shortLevelStr;
  }

...

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

(Continue reading)

goetz | 1 Apr 2002 21:39

Feature request: add support to remove "Thread-" from thread id

Hi

Please add a method String getThreadNumber() to the class
org.apache.log4j.spi.LoggingEvent which
returns the thread number only, i.e. without the (pretty much redundant) text
"Thread-" in front.

I am aware that this is some awkward reverse engineering. It would be better if
the thread implementation itself in the Java library would provide such a
function - is anybody aware of a change request to Sun about that?

Here's a code snippet that would do this:

  public
  String getThreadNumber() {
    if(threadNumber == null) {
	   	String s = (Thread.currentThread()).getName();
	   	if ("main".compareTo(s) == 0)
			threadNumber = "m";
		else
			threadNumber = s.substring(7);
    }
    return threadNumber;
  }

-Bernd.

--

-- 
Bernd Goetz                                     goetz <at> tarsec.com
TARSEC AG                                       Tel +41 1 496 61 11
(Continue reading)

Mark Womack | 2 Apr 2002 06:09

[SUBMIT] GenericMatchFilter.java; SetLocationInfoFilter.java; Log gerNameMatchFilter.java

Enclosed are some new versions of GenericMatchFilter.java and
SetLocationInfoFilter.java.  Also enclosed is LoggerNameMatchFilter.java
which subclasses GenericMatchFilter.java.

GenericMatchFilter and SetLocationInfoFilter are pretty much the same except
for some changes needed to get them to compile properly (deprecated options
stuff?).

LoggerNameMatchFilter subclasses GenericMatchFilter and implements code to
check the logger name in the LoggingEvent against a configured set of names.
If it startsWith() any of the configured logger names, then the event is
accepted.  Could do something similar with level matching as well, but have
not had a chance to write it yet.  Also, I don't claim that
LoggerNameMatchFilter is the most efficient piece of code, but it works as a
demonstration.

Below is a sample configuration using the above filters.  If the logger name
in the logging event matches one of the two "loggerName" parameters for the
LoggerNameMatchFilter filter, then it is configured to return NEUTRAL.
Otherwise it returns ACCEPT and the event is immediatly appended.

If the logger name matches, it continues to the second filter,
SetLocationInfoFilter, which will set the location info and let it continue
on to the appender.

<appender name="logging_server"
class="org.apache.log4j.net.SocketHubAppender">\
  <param name="port" value="5000"/>\
  <param name="locationInfo" value="false"/>\
  <filter class="org.apache.log4j.varia.LoggerNameMatchFilter">\
(Continue reading)

keithnielsen | 2 Apr 2002 09:00

Keith Nielsen/kniels5/DFSI is out of the office.

I will be out of the office starting  04/01/2002 and will not return until
04/05/2002.

I will respond to your message when I return.
Ceki Gülcü | 2 Apr 2002 10:38
Picon
Gravatar

Re: Feature request: add support to remove "Thread-" from thread id


Hi,

Only threads that do not set their name themselves have a thread number. So
your suggestion does not always work.

At 21:39 01.04.2002 +0200, you wrote:
>Hi
>
>Please add a method String getThreadNumber() to the class
>org.apache.log4j.spi.LoggingEvent which
>returns the thread number only, i.e. without the (pretty much redundant) text
>"Thread-" in front.
>
>I am aware that this is some awkward reverse engineering. It would be 
>better if
>the thread implementation itself in the Java library would provide such a
>function - is anybody aware of a change request to Sun about that?
>
>Here's a code snippet that would do this:
>
>   public
>   String getThreadNumber() {
>     if(threadNumber == null) {
>                 String s = (Thread.currentThread()).getName();
>                 if ("main".compareTo(s) == 0)
>                         threadNumber = "m";
>                 else
>                         threadNumber = s.substring(7);
>     }
(Continue reading)

Ceki Gülcü | 2 Apr 2002 11:18
Picon
Gravatar

Re: Feature request: short names for Level/Priority classes


Hi Bernd,

Custom conversion characters in PatternLayout are scheduled for log4j 1.3.
See http://jakarta.apache.org/log4j/docs/plan.html for the plan. I extracted
the relevant text for easy reference:

Custom conversion characters in PatternLayout:

Users often want to add new conversions characters or override the existing 
ones.
This should be made easy using new configuration directives. This feature 
would use
the extensions to XML configuration language mentioned above.

This hopefully answers your request.

At 21:35 01.04.2002 +0200, you wrote:
>Hi
>
>I would like to see short names in the Level class (as I proposed already
>earlier this year). A single character entry would do.
>
>Here some code snippets to realize it:
>
>...
>
>public class Priority {
>
>   int level;
(Continue reading)

Abhijat Thakur | 3 Apr 2002 04:49

Enabling and Disabling Priority For a Category

Hi,

I am using Log4j version 1.1.3. Have two methods one to disable priority
for a category and the other to enable all priorities for a category. I
am only enclosing the relevant portion of the methods. I have two
category COM.BDNA.PL and COM.BDNA.AGENDA.

What happens is that when for COM.BDNA.AGENDA i disable a priority it
disables that priority for COM.BDNA.PL too. And same is the case that
for method enableAll and that is if i have disabled the priority for
COM.BDNA.AGENDA and i call enableAll for category COM.BDNA.PL it enables
all disabled priorities for COM.BDNA.AGENDA. I could understand if these
two categories were in the same Hierarchy but they are in two different
hierarchies. The parents are same but they are two different children. 

In fact after doing a couple of tests i found that if i create a
Category test.foo and disable some priority, then that disables that
priority of all other remainder Categories too like COM.BDNA.Pl,
COM.BDNA.AGENDA.

What am i doing wrong here, since this is not the expected behaviour. 

	/**
	 * Method to disable a priority associated with a Category
	 */
	public static void disablePriority(String categoryName,
                                   String priorityName){
        Category cat = Category.exists(categoryName);
        Priority priority = checkPriority(priorityName); // checking if
priority is valid
(Continue reading)

Jason van Zyl | 3 Apr 2002 14:55

Re: Maven & Log4j

Hi Jason,

At 10:51 31.03.2002 -0500, you wrote:
>Hi,
>
>As part of testing Maven (http://jakarta.apache.org/turbine/maven/)
with
>various Jakarta projects I took a first stab at generating the
>documentation for log4j with Maven. The results are here:
>
>http://24.157.133.102/log4j/

I very much like the new look.

>I need to fix the logo and Ceki I apologize for the appearance of your
>name I need to fix something in the xml mechanism. But you can see that
>there a lot of documents that Maven produces so that you don't have to
>bother with much other then your project specific documentation. There
>is a Maven Documentation section on the bottom left where all the Maven
>generated docs live.

No problem regarding the appearance of my name. My name is already a
test
case for the existing anakia-based system for building the jakarta web
site. I
guess it is better to be a test case rather than a basket case.

You are surely aware that the generated docs are incomplete but
obviously that could be corrected.

(Continue reading)

Abhijat Thakur | 4 Apr 2002 22:20

Logging Centrally

Hi,

I did send this question on users list but did not get an answer so
thats why i am sending it on developers list. We have a distributed
system and use Log4J to do all our logging to files. Our requirement is
that we want to log to a central machine. The two scenarios we have are

1) Either use Log4J to log to syslog of a centralized machine.
2) Log to database.

In syslog all specification of files(appenders) is done in
/etc/syslog.conf. All the file management features like appenders, we
use are of syslog. So what do i specify in my properties.xml file to
load to log4j since i am not associating an appender with a category any
more or do i associate SyslogAppender with  Category. I am not very
clear as to how logging to syslog would work.
In any case how would my /etc/syslog.conf look like for my log messages
comming from Log4J.

If anybody has any idea or opinion on the above two logging scenarios
that we have i would really appreciate it.

Thanks

Abhijat
bugzilla | 7 Apr 2002 19:01
Picon
Favicon

Bug report for Log4j [2002/04/07]

+---------------------------------------------------------------------------+
| Bugzilla Bug ID                                                           |
|     +---------------------------------------------------------------------+
|     | Status: UNC=Unconfirmed NEW=New         ASS=Assigned                |
|     |         OPN=Reopened    VER=Verified    (Skipped Closed/Resolved)   |
|     |   +-----------------------------------------------------------------+
|     |   | Severity: BLK=Blocker     CRI=Critical    MAJ=Major             |
|     |   |           MIN=Minor       NOR=Normal      ENH=Enhancement       |
|     |   |   +-------------------------------------------------------------+
|     |   |   | Date Posted                                                 |
|     |   |   |          +--------------------------------------------------+
|     |   |   |          | Description                                      |
|     |   |   |          |                                                  |
|  569|Ver|Cri|2001-02-09|fully qualified class name used as category name c|
|  851|Ass|Min|2001-03-05|DOM Configurator not throwing exception when targe|
|  900|New|Cri|2001-03-08|RollingFileAppender does not work properly under W|
| 1459|New|Enh|2001-04-23|RollingFileAppender: keep unlimited number of back|
| 1553|Ass|Enh|2001-04-27|A couple of documentation improvements            |
| 1669|Opn|Nor|2001-05-08|Logging 200,000 events in rapid sequence causes As|
| 1960|Ass|Nor|2001-06-01|Extending the standard layout class and implementi|
| 2246|New|Enh|2001-06-20|Throwable indentation & improving String escapeHTM|
| 2251|New|Enh|2001-06-20|org.apache.log4j.helpers.OptionConverter's referen|
| 2276|New|Nor|2001-06-21|stack trace of the exception is not getting logged|
| 2377|Ass|Blk|2001-06-28|A java.lang.ExceptionInInitializerError is thrown |
| 2383|New|Nor|2001-06-28|BasicConfigurator's deprecated method : enableAll(|
| 2498|New|Nor|2001-07-07|WriterAppender doesn't flush footer output        |
| 2586|New|Nor|2001-07-11|Netscpe JRE-Plugin SSL BeanInfo not found problem |
| 2686|New|Enh|2001-07-19|DailyRollingFileAppender with max file size       |
| 2690|New|Nor|2001-07-19|DOMConfigurator cannot be compiled (org.w3c)      |
| 2701|New|Blk|2001-07-19|WriterAppender does not allow logging with other c|
(Continue reading)


Gmane