diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index a618cc229c..0000000000
--- a/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-goEnv*
-dist
\ No newline at end of file
diff --git a/BUILD-INFO.txt b/BUILD-INFO.txt
new file mode 100644
index 0000000000..01310b7371
--- /dev/null
+++ b/BUILD-INFO.txt
@@ -0,0 +1,58 @@
+This is a detailed instruction to reproduce the log4j distribution
+either to verify that the release is reproducable or to prepare
+a hot-fix.
+
+Install VMWare Player or Workstation appropriate for machine.
+
+Download Ubuntu-6.06-1 desktop from http://www.vmware.com/vmtn/appliances/directory/ubuntu.html
+
+Launch Ubuntu 6.06-1 in VMWare Player (user name and password are ubuntu)
+
+Launch Synaptics Package Manager (System > Administration > Synaptic Package Manager), select all available repositories (Settings > Repositories), press Reload button to update list of available packages. Select the following packages for installation: Subversion, mingw32, sun-java6-jdk. Press Apply to install. Exit Synaptics.
+
+Download Maven-2.0.6 from http://maven.apache.org
+Download JMX 1.2.1 Reference Implementation from
+ http://java.sun.com/products/JavaManagement/download.html
+Download JMS 1.1 from http://java.sun.com/products/jms/docs.html
+Unzip all in ~
+
+Copy include/win32/jni_md.h from a Windows JDK to ~
+
+From a command prompt:
+
+$ export JAVA_HOME=/usr/lib/jvm/java-6-sun
+$ export PATH=$JAVA_HOME/bin:/home/ubuntu/maven-2.0.6/bin:$PATH
+$ export JNI_WIN32_INCLUDE_DIR=/home/ubuntu
+$ svn co https://svn.apache.org/repos/asf/logging/log4j/tags/v1_2_15 log4j
+$ mvn install:install-file -DgroupId=com.sun.jdmk -DartifactId=jmxtools \
+ -Dversion=1.2.1 -Dpackaging=jar -Dfile=~/jmx-1_2_1-bin/lib/jmxtools.jar
+$ mvn install:install-file -DgroupId=com.sun.jmx -DartifactId=jmxri \
+ -Dversion=1.2.1 -Dpackaging=jar -Dfile=~/jmx-1_2_1-bin/lib/jmxri.jar
+$ mvn install:install-file -DgroupId=javax.jms -DartifactId=jms \
+ -Dversion=1.1 -Dpackaging=jar -Dfile=~/jms1.1/lib/jms.jar
+$ cd log4j
+$ mvn site assembly:assembly
+
+
+If you intended to deploy jars to the repo or update the site,
+you need to copy your private keys for people.apache.org
+over to ~/.ssh and update ~/maven-2.0.6/conf/settings.xml
+to specify user name and key location.
+
+
* Copyright: PSI-BT AG
diff --git a/doap_log4j.rdf b/doap_log4j.rdf
new file mode 100644
index 0000000000..5d4d5168b4
--- /dev/null
+++ b/doap_log4j.rdf
@@ -0,0 +1,51 @@
+
+
+ What is the use of the How do I get the fully-qualified name of a class in
-a static block? Can the outputs of multiple client request go to
-different log files? Logger instances seem to be create only. Why isn't
-there a method to remove logger instances? Is it possible to direct log output
-to different appenders by level? Why can't Log4J find my properties file in a J2EE or WAR application? Is there a way to get Log4J to automatically reload a configuration file if it changes? Why should I donate my log4j extensions back to the
-project? In case of problems with an application, it is helpful to enable
-logging so that the problem can be located. With log4j it is possible
-to enable logging at runtime without modifying the application binary.
-The log4j package is designed so that log statements can remain in
-shipped code without incurring a high performance cost. It
-follows that the speed of logging (or rather not logging) is capital.
-
- At the same time, log output can be so voluminous that it quickly
-becomes overwhelming. One of the distinctive features of log4j is the
-notion of hierarchical loggers. Using loggers it is
-possible to selectively control which log statements are output at
-arbitrary granularity.
-
- log4j is designed with two distinct goals in mind: speed and
-flexibility. There is a tight balance between these two
-requirements. I believe that log4j strikes the right balance.
-
- By fail-stop, we mean that log4j will not throw unexpected
-exceptions at run-time potentially causing your application to
-crash. If for any reason, log4j throws an uncaught exception,
-please send an email to the log4j-user@jakarta.apache.org
-mailing list. Uncaught exceptions are handled as serious bugs
-requiring immediate attention.
-
-
- Moreover, log4j will not revert to System.out or System.err
-when its designated output stream is not opened, is not writable or
-becomes full. This avoids corrupting an otherwise working program by
-flooding the user's terminal because logging fails. However, log4j
-will output a single message to System.err indicating that logging can
-not be performed.
-
- The DOMConfigurator.configure(String filename) method and its
- variants require a JAXP compatible XML parser, for example Xerces or Sun's
- parser. Compiling the DOMConfigurator requires the presence of a
- JAXP parser in the classpath.
-
- See the Here is an example output using PatternLayout with
-the conversion pattern "%r [%t] %-5p %c{2} %x - %m%n"
-
- The first field is the number of milliseconds elapsed since the
-start of the program. The second field is the thread outputting the
-log statement. The third field is the level of the log
-statement. The fourth field is the rightmost two components of the
-logger making the log request. The fifth field (just before the '-')
-is the nested diagnostic context (NDC). Note the nested diagnostic
-context may be empty as in the first two statements. The text after
-the '-' is the message of the statement.
-
- Loggers are assigned levels. A log statement is printed
-depending on its level and its logger.
-
- Make sure to read the log4j manual
-for more information.
-
- Log behavior can be set using configuration files which are parsed
-at runtime. Using configuration files the programmer can define
-loggers and set their levels.
-
- The Configuration files can be specified in XML. See
- See the various Layout and Appender components for specific
-configuration options.
-
- In addition to configuration files, the user may disable all
-messages belonging to a set of levels. See next item.
-
- For some logger incurs the cost of constructing the message parameter, that is
-converting both integer If you are worried about speed, then write
- This way you will not incur the cost of parameter construction if
-debugging is disabled for logger Yes, there are.
-
- You can name loggers by locality. It turns out
-that instantiating a logger in each class, with the logger name
-equal to the fully-qualified name of the class, is a useful and
-straightforward approach of defining loggers. This approach has
-many benefits:
-
- However, this is not the only way for naming loggers. A common
-alternative is to name loggers by functional
-areas. For example, the "database" logger, "RMI" logger,
-"security" logger, or the "XML" logger.
-
- You may choose to name loggers by functionality and
-subcategorize by locality, as in "DATABASE.com.foo.some.package.someClass" or
-"DATABASE.com.foo.some.other.package.someOtherClass".
-
- You are totally free in choosing the names of your
-loggers. The log4j package merely allows you to manage your
-names in a hierarchy. However, it is your responsibility to define
-this hierarchy.
-
- Note by naming loggers by locality one tends to name things by
-functionality, since in most cases the locality relates closely to
-functionality.
-
- You can easily retrieve the fully-qualified name of a class in a
-static block for class X, with the statement
- Here is the suggested usage template:
-
- Yes. Since release 0.7.0, you can extend the It is simpler to use a nested diagnostic context (NDC). Typically,
-one would NDC.push() client specific information, such as the
-client's hostname, ID or any other distinguishing information when
-starting to handle the client's request. Thereafter, log output will
-automatically include the nested diagnostic context so that you can
-distinguish logs from different client requests even if they are
-output to the same file.
-
- See the For select applications, such as virtual hosting web-servers, the
-NDC solution is not sufficient. As of version 0.9.0, log4j supports
-multiple hierarchy trees. Thus, it is possible to log to different
-targets from the same logger depending on the current context.
-
- Thus, any setter method in Layouts options are also defined by their setter methods. Same goes
-for most other log4j components.
-
-
-
- Yes it is. Setting the Threshold option of any appender
-extending AppenderSkeleton,
-(most log4j appenders extend AppenderSkeleton) to filter out all log
-events with lower level than the value of the threshold
-option.
-
- For example, setting the threshold of an appender to DEBUG also
-allow INFO, WARN, ERROR and FATAL messages to log along with DEBUG
-messages. This is usually acceptable as there is little use for DEBUG
-messages without the surrounding INFO, WARN, ERROR and FATAL
-messages. Similarly, setting the threshold of an appender to ERROR
-will filter out DEBUG, INFO and WARN messages but not ERROR or FATAL
-messages.
-
- This policy usually best encapsulates what the user actually wants
-to do, as opposed to her mind-projected solution.
-
- See sort4.lcf
-for an example threshold configuration.
-
- If you must filter events by exact level match, then you can
-attach a LevelMatchFilter
-to any appender to filter out logging events by exact level match.
-
-
- You may have each process log to a
- The timestamp is created when the logging event is created. That is
-so say, when the While this is the intended behavior, it only recently became so due to
-a bug discovery between version 1.0.4 and 1.1b1. Versions 1.0.4 and before
-had their timestamp regenerated in the converter. In this case the timestamps
-seen in the log file would all appear in order, generated at the time they
-arrived at the log server host according to its local clock.
-
-
-
-The long answer (and what to do about it): J2EE or Servlet containers
-utilize Java's class loading system. Sun changed the way classloading
-works with the release of Java 2. In Java 2, classloaders are
-arranged in a hierarchial parent-child relationship. When a child
-classloader needs to find a class or a resource, it first delegates
-the request to the parent.
-
- Log4J only uses the default So, if you're having problems, try loading the class or resource
-yourself. If you can't find it, neither will Log4J. ;)
-
- Yes. Both the DOMConfigurator and the PropertyConfigurator support
-automatic reloading through the The NT Event Viewer relies on message resource DLLs to
-properly view an event message. The NTEventLogAppender.dll contains
-these message resources, but that DLL must be copied to
-%SYSTEMROOT%\SYSTEM32 for it to work properly.
-
-
- Unfotunately, the logger names are hardcoded within the message
-resource DLL (see previous question about NTEventLogAppender), so
-there isn't any easy way to override those dynamically... in fact, I
-don't think it's possible to do it, as you'd have to modify the DLL
-resources for every application. Since most native applications don't
-use the Logger column anyway...
-
- We are very careful not to change the log4j client API so that
-newer log4j releases are backward compatible with previous
-versions. We are a lot less scrupulous with the internal log4j
-API. Thus, if your extension is designed to work with log4j version
- If your extensions are useful then someone will eventually write an
-extension providing the same or very similar functionality. Your
-development effort will be wasted. Unless the proprietary log4j
-extension is business critical, there is little reason for not
-donating your extensions back to the project.
-
- There is nothing more irritating than finding the bugs in
- debugging (i.e. logging) code. Writing a test case takes some
- effort but is crucial for a widely used library such as
- log4j. Writing a test case will go a long way in earning you the
- respect of fellow developers. See the tests/ directory for exiting
- test cases.
-
- Alternating between indentation styles makes it hard to
- understand the source code. Make it hard on yourself but easier
- on others. Log4j follows the Code Conventions for
- the JavaTM Programming Language.
-
- One of the important advantages of log4j is its compatibility with
- JDK 1.1.x.
-
- It's all about the application not about logging.
-
- Authoring software is like parenting. It takes many
- years to raise a child.
-
- The log4j project is hosted at http://jakarta.apache.org/log4j/.
-
- Here is a list of commonly encountered problems when using log4j: log4j:WARN No such property
- [xyz] in some.appender.or.layout
- Log4j does not have a default logging target.
- It is the user's responsibility to ensure that all
- categories can inherit an appender. This can be easily
- achieved by attaching an appender to the root category. The reason for observing duplicates in log4j output is
- either due to having added the same appender multiple times
- to the same category (typically root) or having added the
- same appender to different categories ignoring the fact that
- appenders are inherited cumulatively. log4j does not eliminate appender duplicates. In other
- words, if you add the same appender to a category n
- times, that appender will be invoked n times to
- append to its target. A slightly different cause is adding different appenders
- all sharing the same underlying output target to some
- category. In the most common occurrence of this phenomenon,
- the BasicConfigurator.configure() method is invoked multiple
- times. Each time it is invoked, this method adds an appender
- with a One other common mistake is to forget that appenders are
- inherited cumulatively from the hierarchy. For example, if
- you add an appender, say The PropertyConfigurator relies on
- The spaces in the value, i.e. You can remedy this problem by disabling the JIT compiler and by
- compiling the code without the -O option. In wrappers or subclasses of Category
-
- Wrappers or subclasses of This approach will work correctly in all cases except if
- the class invoking the extended category instance has the
- same prefix as the extended category class. For example,
- calling an instance of This exception is thrown because log4j does not support
-homonyms. For example, the following will systematically throw a
- By default, the To address this problem, the
- The Naturally you should check the classpath. But you should also
-be aware of the presence of multiple classloaders in the JVM:
- If you place log4j.jar in the Servlet, JSP and EJB containers inside of application servers
-usually have their own special classloaders in addition to the
-three mentioned above. While this provides for a greater
-degree of separation for different webapps, EJB containers and the
-application server runtime itself, it can provide headaches to the
-uninitiated.
-
- Classloaders are usually hierarchically related. The bootstrap
-loader forms the root with the extension loader as its child. The
-application loader is the child of the extension loader and it's
-this "app loader" that we use by default when we write standalone
-Java programs.
-
- Upon receiving a class load request, the classloader usually
-delegates it to the parent before attempting to service the request.
-This allows the bootstrap and extension loaders to deliver any classes
-that are part of the JDK or its extensions. Only after this delegation
-fails will the classloader attempt to find the class itself. Note that
-classloaders do not delegate requests to children.
-
- Application servers often use the application loader for its runtime
-classes and create separate classloaders for its webapp and EJB
-containers. These additional classloaders may descend directly
-from the app server's runtime classloader. If log4j is placed in the
-classpath of a webapp classloader, another webapp classloader will not
-necessarily see it. EJBs wouldn't see it either. If log4j is intended
-to be made available to all objects participating in the app server, it
-should be included in the classpath of a classloader high enough in the
-classloader hierarchy to be seen by all classloaders.
-
- A good article on classloaders with examples using IBM's WebSphere
-application server can be found
-here
-in PDF format.
-
- I cannot log to syslogd under linux.
-
-If you are trying to log to the Unix syslog under Linux using the SyslogAppender,
-then the Linux syslog daemon must be configured to accept log input
-from the network. Otherwise, you will get an This can be done by adding the If during log4j configuration you get a warning about an inexistent
-property, then you have probably misspelled a property or entered a
-truly unrecognized property for the component you are trying to
-configure in the configuration file.
-
- Log4j version 1.0 did not complain about unrecognized properties
-whereas log4j version 1.1 and later do complain.
-
-
-
-
-
-
diff --git a/docs/critique.html b/docs/critique.html
deleted file mode 100644
index 55c2d704f6..0000000000
--- a/docs/critique.html
+++ /dev/null
@@ -1,294 +0,0 @@
-
- I consider it quite distasteful to criticize other people's work,
-especially in public. However, since the logging API included in JDK
-1.4 will be considered by many as the "standard", I feel compelled to
-react. I am not alone in my criticism of JSR47, Greg Davis has his own
-set of comments.
-
- The JDK 1.4 logging API is a result of the JSR47
-effort, led by Graham Hamilton.
-
- Before delving into the details, some historical perspective is in
-order. I am the founder of the log4j project. I participated in the
-specification of the JSR47 API, although not as an expert. In 1999, I
-was still working for IBM and could not join the experts group because
-big blue had already Chris Barlock as a member in the JSR47 experts
-group. Chris is the author of IBM's
-logging toolkit for Java.
-
- On the surface, his toolkit has heavily influenced the JSR47
-API. In particular, the two share the same basic components, namely
-loggers, levels, handlers and formatters. In log4j, these components
-are called categories, priorities, appenders and layouts
-respectively. Pairwise, they are identical in purpose. As such, the
-terms logger and category, level and priority, handler and appender,
-formatter and layout will be used interchangeably in the remainder of
-this document.
-
- Even after a casual review it should be apparent that the log4j and
-JSR47 APIs are very similar. For one, they are the only
-logging APIs which are based on a named hierarchy. If you understand
-one API, then understanding the concepts of the other should be a
-breeze. There are differences however.
-
- In JSR47, a parent logger knows about its children but not the
-other way around. Children do not have links to their parent. For
-example, the logger named In log4j, it is exactly the other way around. A log4j category
-contains a link to its parent but a parent does not have links to its
-children.
-
- At first glance, this might look like a mundane implementation
-detail but it is actually quite fundamental.
-
- In JSR47, when you set the level of a logger, say
- In log4j, changing the priority of a category involves the change
-of a single field. Children categories dynamically inherit the
-priority of their parent by traversing the hierarchy tree upwards.
-
- It follows that with JSR47 if you configure the level for logger
-"foo.bar1" before configuring the level for "foo", then the latter
-instruction will overwrite the first exactly as if the first
-instruction for configuring "foo.bar1" had never
-existed. Configuration order dependence is not a show stopper but
-it is something that will bite you time and again.
-
- In contrast, in log4j categories can be configured in any
-order. You never have to worry about configuration order.
-
- In JSR47, a logger does not walk the hierarchy to inherit its level
-but possesses a copy of it.
-
- Unfortunately, in the JSR47 API, handlers cannot be inherited
-because it would be prohibitively expensive to let each logger to
-contain a distinct Vector of all inherited handlers, especially in
-large trees.
-
- To circumvent this problem by JSR47 defines global handlers. A
-logger logs to global handlers and to the handlers attached to itself
-directly. It does not inherit any handlers from the
-hierarchy.
-
- In log4j, appenders are inherited additively from the hierarchy. A
-category will log to the appenders attached to itself as well as the
-appenders attached to its ancestors. This might not seem like much
-until the day you need handler inheritance; probably a week after you
-decide to adopt a logging API.
-
- Similarly, in log4j resource bundles are inherited from the
-hierarchy. In JSR47, a resource bundle must be attached to
-each logger individually. There is no resource bundle inheritance in
-JSR47. In practice, this means that you have to choose between
-internationalization and the benefits of the named logger
-hierarchy. It's one or the other. This limitation is particularly
-surprising because support for internationalization is advocated as
-one of the primary advantages of the JSR47 API.
-
- JSR 47 defines the levels Having three debugging levels Log4j in contrast has a limited but self-evident set of priorities:
- Both JSR47 and log4j allow the user to extend the set of
-priorities. Log4j supports subclasses of priorities in configuration
-files as well as across the wire. JSR47 does not.
-
- Log4j has appenders capable of logging to the console, to files, to
-Unix Syslog daemons, to Microsoft NT EventLoggers, remote servers, to
-JMS channels, automatically generate email etc. It can roll log files
-by size or date and log asynchronously.
-
- JSR47 can log to the console, to files, to sockets and to a memory
-buffer.
-
- Log4j has an extensible and powerful layout called the
- Log4j supports configuration through property files as well as XML
-documents. JSR47 currently admits only property files. Moreover, the
-language of JSR47 configuration files is very weak. In particular, you
-can only configure one instance of a given handler class. This
-means that you can log to just one file at a time.
-
- There are many other details in which log4j differs from
-JSR47. Even if the log4j core is small, the project contains a total
-of over 30'000 lines of well-tested code. JSR47 contains about 5'000
-lines of code.
-
- Log4j has been around for a number of years, enjoys the support of
-five active developers (committers) and is being used in thousands of
-projects. Our site gets over 500 downloads each and every day, and the
-numbers are on the rise. Log4j has been ported to C++ and
-Python. Companies are also offering commercial products extending
-log4j.
-
- Here is a short list of opensource projects or sites that are known
-to use log4j.
-
- By the way, log4j runs fine under JDK 1.1 and above. JSR 47 will
-run under JDK 1.4 and only under JDK 1.4. Interestingly enough, no
-package shipped with JDK 1.4 is using the JSR47 API.
-
- Brian R. Gilstrap has re-written JSR47 API to
-run under JDK 1.2 and 1.3. He has also published an article
-in JavaWorld. This is all very promising but since
- Jochen Hiller had observed this problem in early 2001 when he
-implemented the JSR47 API by wrapping log4j.
-
- Note that any third-party implementation using the
- In log4j, under no circumstances are exceptions thrown at the
-user. However, all appenders have an associated
- An But again who cares about errors, right?
-
- Logging performance must be studied in three distinct cases: when
-logging is turned off, when turned on but due to priority comparison
-logic not enabled, and when actually logging. Please refer to the log4j manual for a more detailed
-discussion of logging performance.
-
- When logging is turned on, log4j will be about two to three times
-slower to decide whether a log statement is enabled or not. This is
-due to the dynamic nature of log4j which requires it to walk the
-hierarchy. To give you an idea about the figures involved, under JDK
-1.4 beta, we are talking about 90 nanoseconds instead of 30
-nanoseconds on a 800Mhz Intel processor. In other words, one
-million disabled logging requests will cost under a second in both
-environments.
-
- In a shipped binary, you can turn off logging entirely and both
-APIs will perform identically. Note that if one is not careful, the
-cost of parameter construction before invoking a disabled log
-statement will overwhelm any other performance consideration.
-Regardless of the API you decide to use, logging statements should
-never be placed in tight loops, for example, before or after an
-element swap instruction in a sort algorithm.
-
- In log4j, caller localization information is optional whereas in
-JSR47 it is always extracted. Since the extraction of caller
-localization is a very slow operation, in the common case where caller
-information is not needed, log4j will log the same information 4 to
-100 times faster.
-
-
-
-
diff --git a/docs/deepExtension.html b/docs/deepExtension.html
deleted file mode 100644
index 05e0eb7cbb..0000000000
--- a/docs/deepExtension.html
+++ /dev/null
@@ -1,735 +0,0 @@
-
-
-This article describes a systematic way to extend the
-log4j API to include
-additional attributes formatted using the
-
-
-
-This article assumes familiarity with the log4j
-User Manual. It builds on fundamental
-classes described in both the User Manual and the
-Javadoc API. To assist in illustrating the
-concepts, a simple case study will be developed along side the
-explanations. The resulting classes may be used as a template
-for your own extensions. Condensed (i.e. statements compressed,
-comments removed) snippets of the case study code
-are included in this document.
-
-
-
-It seems odd to use "b" for the component name. Presently
-
-In principle, if the steps described below are followed closely, there is
-not a need to understand how the extended classes will be used by log4j.
-But sometimes software development can be entirely unprincipled. You may
-wish to extend log4j in a different manner than describe here or you may
-make a mistake that requires knowledge of what is really going on. (Heaven
-forbid there be a mistake in this document). In any case, it doesn't hurt
-to get an idea of what's going on.
-
-The following describes a "typical" logging scenario in the un-extended log4j
-case.
-
-
-
-
-
-
-When the
-When the
-
-
-The above discussing involved most of the classes that we must extend or
-implement.
-
-
-
-It's helpful if you know the attributes you wish to add and a
-
-Before we dig in, I should give the standard lecture on comments.
-If the log4j library were not well documented, it would be useless
-to everyone but the log4j creators; likewise with your extensions.
-Much like eating vegetables and saving the environment, we all agree
-commenting code properly should be done. Yet it is often sacrificed
-for more immediate pleasures. We all write code faster without
-comments; especially those pesky Javadoc comments. But the reality
-is that the utility of undocumented code fades exponentially with time.
-
-Since the log4j product comes with Javadoc comments together with
-the documentation it produces, it makes sense to include Javadoc
-comments in your extensions. By their very nature, logging tools
-are strong candidates for reuse. They can only be independently
-re-used if they are supported by strong documentation component.
-
-This all having been said, I have elected to remove most comments from
-examples in the interest of space rather than including them to serve
-as a nagging reminder. The reader is referred to the case study source
-code files for a Javadoc version and a
-Javadoc website
-for more information on Javadoc conventions.
-
-
-
-The constructor demonstrates that in most cases, the
-
-Our job will be to subclass
-The extension to
-
-It also differs in that the format constants are characters
-rather than integers.
-
-
-
-
-
-
-
-Most of the code below is standard getter/setter verbage which has been
-somewhat abbreviated. The notable parts are in bold. We add five more
-attributes to
-The
-The
-The
-
-
-
-Below is a snippet from
-
-
-
-The consequence of a configurator creating the super class by
-mistake is merely that the extra attributes will not appear in
-the log output. All other attributes are conveyed properly.
-
-
-
- Make sure to read the user manual
-in addition to this javadoc documentation.
-
-
diff --git a/docs/praise.html b/docs/praise.html
deleted file mode 100755
index e6d10d0e9b..0000000000
--- a/docs/praise.html
+++ /dev/null
@@ -1,266 +0,0 @@
-
- JavaWorld, April 2001
-
- Log4j is an incredibly well designed and functional logging tool. I
-caught the religion last summer and with every project I work on, most
-everyone agrees it's a must know/have tool. Previously I was using
-another Java logging library developed internally within my company
-which I liked. I had no desire to learn another but did so for the
-sake of due diligence. Log4j has the following features which set it
-apart from others I have seen.
-
- Highly configurable - the ability to configure the
-properties of your loggers (called Categories in log4j) from within a
-property file is indispensible. This allows you to change the
-characteristics of your logging without changing code. You can change
-the logging level, the format of the output and the output targets
-very easily. One can also use XML files (though I haven't).
-
- Unobtrusive - I'm finishing a project where we started using another
-logging tool. The log statements were clumsily long and required using
-predefined constants that were hard to remember. When writing the
-initial code, "System.out.println" was so much easier to type that
-people did this for tracing with the best of intentions to place
-legitimate logging in later. You know the story. It never
-happened. Log4j statements are shorter than "System.out.println"
-statements. This encourages people to actually use it rather than
-simply agreeing to.
-
- Easy configuration - With just one statement, log4j will
-configure itself with a set of defaults that are useful until you get
-around to actually writing your property file, XML file or
-whatever. Like the point just made before, this allows log4j to be
-used at the outset of coding rather than having to wait because you
-haven't considered how you wish logging to be configured. The
-application code itself does not have to know how logging will be
-configured.
-
- Performance Concerns - Since Java does not use pre-processor
-macros, most Java tracing is always compiled into the code. That means
-that the decision to compile is made at runtime. There are times when
-performance is so paramount that even checking whether to log is a
-concern. There are other extremes where other delays make this
-insignificant so that the performance is easily sacrificed for the
-increased amount of information logged (such as method name, class
-name and line number in source code). The log4j javadoc documentation
-explains which information elements are quickly logged and which may
-compromise performance. It also includes benchmarks that demonstrate
-how fast certain statements are logged for a few sample machine
-configurations.
-
- Hierarchical Categories - This is highly useful in component
-based development. Each component has its own set of logging
-categories. When individually tested, the properties of these
-categories may be set however the developer wishes. When combined with
-other components, the categories inherit the properties determined by
-the integrator of the components. One can selectively elevate logging
-priorities on one component without affecting the other
-components. This is useful when you need a detailed trace from just a
-single component without crowding the trace file with messages from
-other components. All this can be done with property files - no change
-in the code is required.
-
- Easily specified output format - Some Java and OO purist
-disagree with me on this, but allowing one to use printf-style output
-format specification is powerful, convenient and compact. Log4j
-provides a Layout class with this capability. Of course, for those who
-wish, you may implement the Layout interface yourself with something
-"more OO". Naturally, the printf-style pattern can be specified in a
-property file.
-
- Customization - Like other loggers, log4j is interface-based
-making it possible to extend. Log4j supplies useful implementations
-that are extended easily without having to implement the interface
-from scratch.
- Paul Glezen (pglezen at atdial.net), December 3rd, 2000
-
- Denis Balazuc (denis.balazuc at trader.com), December 8th, 2000
-
- Paul Hyndman (PaulHyndman at mynd.com), November 29th, 2000
-
- Rich Coco (racoco at celoxnetworks.com), November 16th, 2000
-
-
-
- Richard King (Richard.King at capgemini.co.uk), October 25th, 2000
-
- It's funny when I get an email from someone at work who's using the
-toolkit with a "it didn't work" question, and I ask them to check out
-the log... due to the coolness of log4j, they can track down their
-mistake immediately.
-
- Christopher Taylor (cstaylor at pacbell.net), September 2nd, 2000
-
- Manish Balsara (manishb at aumsoft.com) August 28th, 2000
-
- Guy Nirpaz, Java Architect (guyn at tantian.com) August
-14th, 2000
-
- Alice Nakajima (alice.t.nakajima at saic.com) May 10th,
-2000
-
-
- Zeng Qiang (zeng.qiang at europeloan.com) April 26th, 2000
-
- Jianbo Wang (jiwang at Daleen.com) April
-25th, 2000
-
- Actually I'm evaluating the log4j package for use in our commercial
-projects. We have our own tracer package which is by far less
-powerfull and less configurable than yours.
- Joerg Palmer (Joerg.Palmer at Compart.net) April 14th, 2000
-
-
- Nelson Minar CTO, Popular Power, Inc. (nelson at popularpower.com) April 14th, 2000
-
- Anthony (ant at sanlam.co.za) April 13th, 2000
-
-
- Andrew Harris (Andrew.Harris at capgemini.co.uk) April 10th, 2000
-
- So here is my "THANK YOU" to all the contributors.
-I think I'll join the club.
- Avy Sharell (asharell at club-internet.fr) March 8th, 2000
-
-
- We are using it in the FREE e-democracy project
-http://www.thecouch.org/free/ to provide an effective security audit
-trail in our electronic voting software.
- Jason Kitcat (jeep at thecouch.org) March 29th, 2000
-
-
- Steven Marcus (srnm at awaretechnologies.com) February 19th, 2000
-
- Sebastien Sahuc (ssahuc at imediation.com) January 4th, 2000
-
-
- Jens Uwe Pipka (jens.pipka at gmx.de) October 25th, 1999
-
- See Examples
+ section in the LogFactor5 user guide.
+ Add the fatal() family of methods to the Category
+ class. Moreover, the EMERG priority has been removed from the
+ Priority class. This priority has been replaced by the FATAL
+ priority that is more widely accepted. This change will
+ require EMERG log statements to be replaced by FATAL log
+ statements. Assuming EMERG log statements are rare, this should
+ have a small but bearable impact on existing client code. Moreover, the Unix Syslog priorities ALERT, CRIT and NOTICE are no
+ longer recognized. Support for these priorities was minimal and
+ few users should suffer from these changes. Add support for object rendering. It is now possible to register
+ an object renderer for a given object type. When the given object
+ needs to be logged log4j will invoke the corresponding renderer to
+ transform the object into a String. As a result of this enhancement, all the String forms of all the
+ printing methods such as debug(String), info(String) have been
+ removed as they are no longer necessary. This change should be
+ backward compatible but requires recompilation of old client
+ code. Thanks to Michael Smith for noting the recompilation
+ requirement. Created a new class called Category to manipulate categories
+ instead of plain Strings. The new class is just as easy to use.
+ However, the evaluation of whether to log or not to log is at least
+ 10 times faster. The NOP class performance remain unaffected by the
+ change. (You can't improve on the performance of an empty function
+ call.) Many thanks to Alex Blewitt "Alex.Blewitt@ioshq.com" for his
+ valuable comments. He was the first to observe that finding Strings
+ in a hash table was an expensive operation. This change will require some recoding on your part. See the FAQ
+ for more details. We now enforce a policy where the OutputStream set by
+ setOutputStream is a user managed resource whereas the OutputStream
+ opened using setLogFile is the Log class' responsibility. The setLogFile method now closes any previous OutputStream if only
+ if opened through setLogFile. If the previous OutputStream was
+ opened by the user and set through setOutputStream the previous
+ OutputStream is untouched. Similarly, setOutputStream will close any previous OutputStream if
+ and only if it was opened using setLogFile. Changed the behavior of the (private) Log.Append method in case of
+ failure to write to the OutputStream. Previously, in case of failure, we reverted to System.err. Now, we
+ emit a warning message and discard all future log messages. The
+ new behavior is consistent with our current unreliable logging
+ semantics. The change prevents an otherwise functional program
+ from failing because the terminal is flooded with logging messages. The AsyncAppender will collect the events sent to it and then
- dispatch them to all the appenders that are attached to it. You can
- attach multiple appenders to an AsyncAppender.
-
- The AsyncAppender uses a separate thread to serve the events in
- its bounded buffer.
-
- Refer to the results in {@link org.apache.log4j.performance.Logging}
- for the impact of using this appender.
-
- Important note: The Location information extraction is comparatively very slow and
- should be avoided unless performance is not a concern.
- */
- public
- void setLocationInfo(boolean flag) {
- locationInfo = flag;
- }
-
-
- /**
- The BufferSize option takes a non-negative integer
- value. This integer value determines the maximum size of the
- bounded buffer. Increasing the size of the buffer is always
- safe. However, if an existing buffer holds unwritten elements,
- then decreasing the buffer size will result in event
- loss. Nevertheless, while script configuring the
- AsyncAppender, it is safe to set a buffer size smaller than the
- {@link #DEFAULT_BUFFER_SIZE default buffer size} because
- configurators guarantee that an appender cannot be used before
- being completely configured.
- */
- public
- void setBufferSize(int size) {
- bf.resize(size);
- }
-
- /**
- Returns the current value of the BufferSize option.
- */
- public
- int getBufferSize() {
- return bf.getMaxSize();
- }
-
-}
-// ------------------------------------------------------------------------------
-// ------------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-class Dispatcher extends Thread {
-
- BoundedFIFO bf;
- AppenderAttachableImpl aai;
- boolean interrupted = false;
- AsyncAppender container;
-
- Dispatcher(BoundedFIFO bf, AsyncAppender container) {
- this.bf = bf;
- this.container = container;
- this.aai = container.aai;
- // set the dispatcher priority to lowest possible value
- this.setPriority(Thread.MIN_PRIORITY);
- this.setName("Dispatcher-"+getName());
- // set the dispatcher priority to MIN_PRIORITY plus or minus 2
- // depending on the direction of MIN to MAX_PRIORITY.
- //+ (Thread.MAX_PRIORITY > Thread.MIN_PRIORITY ? 1 : -1)*2);
-
- }
-
- void close() {
- synchronized(bf) {
- interrupted = true;
- // We have a waiting dispacther if and only if bf.length is
- // zero. In that case, we need to give it a death kiss.
- if(bf.length() == 0) {
- bf.notify();
- }
- }
- }
-
-
-
- /**
- The dispatching strategy is to wait until there are events in the
- buffer to process. After having processed an event, we release
- the monitor (variable bf) so that new events can be placed in the
- buffer, instead of keeping the monitor and processing the remaining
- events in the buffer.
-
- Other approaches might yield better results.
-
- */
- public
- void run() {
-
- //Category cat = Category.getInstance(Dispatcher.class.getName());
-
- LoggingEvent event;
-
- while(true) {
- synchronized(bf) {
- if(bf.length() == 0) {
- // Exit loop if interrupted but only if the the buffer is empty.
- if(interrupted) {
- //cat.info("Exiting.");
- return;
- }
- try {
- //LogLog.debug("Waiting for new event to dispatch.");
- bf.wait();
- } catch(InterruptedException e) {
- LogLog.error("The dispathcer should not be interrupted.");
- break;
- }
- }
- event = bf.get();
- if(bf.wasFull()) {
- //LogLog.debug("Notifying AsyncAppender about freed space.");
- bf.notify();
- }
- } // synchronized
-
- // The synchronization on parent is necessary to protect against
- // operations on the aai object of the parent
- synchronized(container.aai) {
- if(aai != null && event != null) {
- aai.appendLoopOnAppenders(event);
- }
- }
- } // while
- }
-}
diff --git a/src/java/org/apache/log4j/CategoryKey.java b/src/java/org/apache/log4j/CategoryKey.java
deleted file mode 100644
index b3c94ad3c5..0000000000
--- a/src/java/org/apache/log4j/CategoryKey.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j;
-
-/**
- CategoryKey is heavily used internally to accelerate hash table searches.
- @author Ceki Gülcü
-*/
-class CategoryKey {
-
- String name;
- int hashCache;
-
- CategoryKey(String name) {
- this.name = name.intern();
- hashCache = name.hashCode();
- }
-
- final
- public
- int hashCode() {
- return hashCache;
- }
-
- final
- public
- boolean equals(Object rArg) {
- if(this == rArg)
- return true;
-
- if(rArg != null && CategoryKey.class == rArg.getClass())
- return name == ((CategoryKey)rArg ).name;
- else
- return false;
- }
-}
diff --git a/src/java/org/apache/log4j/ConsoleAppender.java b/src/java/org/apache/log4j/ConsoleAppender.java
deleted file mode 100644
index fc1447461f..0000000000
--- a/src/java/org/apache/log4j/ConsoleAppender.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j;
-
-import java.io.OutputStreamWriter;
-import org.apache.log4j.helpers.LogLog;
-
-/**
- ConsoleAppender appends log events to This method first checks if this category is WARNING Note that passing a {@link Throwable} to this
- method will print the name of the See {@link #fine(Object)} form for more detailed information.
-
- @param message the message object to log.
- @param t the exception to log, including its stack trace. */
- //public
- //void fine(Object message, Throwable t) {
- // if(repository.isDisabled(Level.DEBUG_INT))
- // return;
- // if(Level.DEBUG.isGreaterOrEqual(this.getChainedLevel()))
- // forcedLog(FQCN, Level.FINE, message, t);
- //}
-
- /**
- Retrieve a logger by name.
- */
- static
- public
- Logger getLogger(String name) {
- return LogManager.getLogger(name);
- }
-
- /**
- Same as calling This method is intended to be used by sub-classes.
-
- @param name The name of the logger to retrieve.
-
- @param factory A {@link LoggerFactory} implementation that will
- actually create a new Instance.
-
- @since 0.8.5 */
- public
- static
- Logger getLogger(String name, LoggerFactory factory) {
- return LogManager.getLogger(name, factory);
- }
-
-}
diff --git a/src/java/org/apache/log4j/ProvisionNode.java b/src/java/org/apache/log4j/ProvisionNode.java
deleted file mode 100644
index 4faf539470..0000000000
--- a/src/java/org/apache/log4j/ProvisionNode.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j;
-
-import java.util.Vector;
-
-class ProvisionNode extends Vector {
-
- ProvisionNode(Logger logger) {
- super();
- this.addElement(logger);
- }
-}
diff --git a/src/java/org/apache/log4j/chainsaw/ExitAction.java b/src/java/org/apache/log4j/chainsaw/ExitAction.java
deleted file mode 100644
index 8fb0ce8c9b..0000000000
--- a/src/java/org/apache/log4j/chainsaw/ExitAction.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-package org.apache.log4j.chainsaw;
-
-import java.awt.event.ActionEvent;
-import javax.swing.AbstractAction;
-import org.apache.log4j.Category;
-
-/**
- * Encapsulates the action to exit.
- *
- * @author Oliver Burn
- * @version 1.0
- */
-class ExitAction
- extends AbstractAction
-{
- /** use to log messages **/
- private static final Category LOG = Category.getInstance(ExitAction.class);
- /** The instance to share **/
- public static final ExitAction INSTANCE = new ExitAction();
-
- /** Stop people creating instances **/
- private ExitAction() {}
-
- /**
- * Will shutdown the application.
- * @param aIgnore ignored
- */
- public void actionPerformed(ActionEvent aIgnore) {
- LOG.info("shutting down");
- System.exit(0);
- }
-}
diff --git a/src/java/org/apache/log4j/config/PropertySetterException.java b/src/java/org/apache/log4j/config/PropertySetterException.java
deleted file mode 100644
index b8cb0e00a5..0000000000
--- a/src/java/org/apache/log4j/config/PropertySetterException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.APL file.
- */
-
-package org.apache.log4j.config;
-
-/**
- * Thrown when an error is encountered whilst attempting to set a property
- * using the {@link PropertySetter} utility class.
- *
- * @author Anders Kristensen
- * @since 1.1
- */
-public class PropertySetterException extends Exception {
- protected Throwable rootCause;
-
- public
- PropertySetterException(String msg) {
- super(msg);
- }
-
- public
- PropertySetterException(Throwable rootCause)
- {
- super();
- this.rootCause = rootCause;
- }
-
- /**
- Returns descriptive text on the cause of this exception.
- */
- public
- String getMessage() {
- String msg = super.getMessage();
- if (msg == null && rootCause != null) {
- msg = rootCause.getMessage();
- }
- return msg;
- }
-}
\ No newline at end of file
diff --git a/src/java/org/apache/log4j/helpers/FormattingInfo.java b/src/java/org/apache/log4j/helpers/FormattingInfo.java
deleted file mode 100644
index a8b5e41a38..0000000000
--- a/src/java/org/apache/log4j/helpers/FormattingInfo.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-
-package org.apache.log4j.helpers;
-
-
-/**
- FormattingInfo instances contain the information obtained when parsing
- formatting modifiers in conversion modifiers.
-
- @author Jim Cakalic
- @author Ceki Gülcü
-
- @since 0.8.2
- */
-public class FormattingInfo {
- int min = -1;
- int max = 0x7FFFFFFF;
- boolean leftAlign = false;
-
- void reset() {
- min = -1;
- max = 0x7FFFFFFF;
- leftAlign = false;
- }
-
- void dump() {
- LogLog.debug("min="+min+", max="+max+", leftAlign="+leftAlign);
- }
-}
-
diff --git a/src/java/org/apache/log4j/helpers/Loader.java b/src/java/org/apache/log4j/helpers/Loader.java
deleted file mode 100644
index 222c2ccffe..0000000000
--- a/src/java/org/apache/log4j/helpers/Loader.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j.helpers;
-
-import java.net.URL;
-//import java.awt.Image;
-//import java.awt.Toolkit;
-
-/**
- Load resources (or images) from various sources.
-
- @author Ceki Gülcü
- */
-
-public class Loader {
-
- static final String TSTR = "Caught Exception while in Loader.getResource. This may be innocuous.";
-
- // We conservatively assume that we are running under Java 1.x
- static private boolean java1 = true;
-
- static {
- String prop = OptionConverter.getSystemProperty("java.version", null);
-
- if(prop != null) {
- int i = prop.indexOf('.');
- if(i != -1) {
- if(prop.charAt(i+1) != '1')
- java1 = false;
- }
- }
- }
-
- /**
- This method will search for For example, the socket node might decide to log events to a
- local file and also resent them to a second socket node.
-
- @author Ceki Gülcü
-
- @since 0.8.4
-*/
-public class SocketNode implements Runnable {
-
- Socket socket;
- LoggerRepository hierarchy;
- ObjectInputStream ois;
-
- static Logger logger = Logger.getLogger(SocketNode.class);
-
- public
- SocketNode(Socket socket, LoggerRepository hierarchy) {
- this.socket = socket;
- this.hierarchy = hierarchy;
- try {
- ois = new ObjectInputStream(
- new BufferedInputStream(socket.getInputStream()));
- }
- catch(Exception e) {
- logger.error("Could not open ObjectInputStream to "+socket, e);
- }
- }
-
- //public
- //void finalize() {
- //System.err.println("-------------------------Finalize called");
- // System.err.flush();
- //}
-
- public void run() {
- LoggingEvent event;
- Logger remoteLogger;
-
- try {
- while(true) {
- event = (LoggingEvent) ois.readObject();
- remoteLogger = hierarchy.getLogger(event.categoryName);
- event.logger = remoteLogger;
- if(event.level.isGreaterOrEqual(remoteLogger.getEffectiveLevel())) {
- remoteLogger.callAppenders(event);
- }
- }
- }
- catch(java.io.EOFException e) {
- logger.info("Caught java.io.EOFException closing conneciton.");
- } catch(java.net.SocketException e) {
- logger.info("Caught java.net.SocketException closing conneciton.");
- } catch(IOException e) {
- logger.info("Caught java.io.IOException: "+e);
- logger.info("Closing connection.");
- } catch(Exception e) {
- logger.error("Unexpected exception. Closing conneciton.", e);
- }
-
- try {
- ois.close();
- } catch(Exception e) {
- logger.info("Could not close connection.", e);
- }
- }
-}
diff --git a/src/java/org/apache/log4j/net/test/Loop.java b/src/java/org/apache/log4j/net/test/Loop.java
deleted file mode 100644
index e5242f3546..0000000000
--- a/src/java/org/apache/log4j/net/test/Loop.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-package org.apache.log4j.net.test;
-
-import org.apache.log4j.*;
-import org.apache.log4j.net.SocketAppender;
-
-public class Loop {
-
- public static void main(String[] args) {
-
-
- Category root = Category.getRoot();
- Category cat = Category.getInstance(Loop.class.getName());
-
- if(args.length != 2)
- usage("Wrong number of arguments.");
-
- String host = args[0];
- int port = 0;
-
- try {
- port = Integer.valueOf(args[1]).intValue();
- }
- catch (NumberFormatException e) {
- usage("Argument [" + args[1] + "] is not in proper int form.");
- }
-
- SocketAppender sa = new SocketAppender(host, port);
- Layout layout = new PatternLayout("%5p [%t] %x %c - %m\n");
- Appender so = new ConsoleAppender(layout, "System.out");
- root.addAppender(sa);
- root.addAppender(so);
-
- int i = 0;
-
- while(true) {
- NDC.push(""+ (i++));
- cat.debug("Debug message.");
- root.info("Info message.");
- NDC.pop();
- }
-
- }
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println(
- "Usage: java " +Loop.class.getName() + " host port");
- System.exit(1);
- }
-
-
-}
diff --git a/src/java/org/apache/log4j/net/test/SMTPMin.java b/src/java/org/apache/log4j/net/test/SMTPMin.java
deleted file mode 100644
index 6777157b08..0000000000
--- a/src/java/org/apache/log4j/net/test/SMTPMin.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-package org.apache.log4j.net.test;
-
-import org.apache.log4j.*;
-
-public class SMTPMin {
-
- static Category cat = Category.getInstance(SMTPMin.class);
-
- public
- static
- void main(String argv[]) {
- if(argv.length == 1)
- init(argv[0]);
- else
- usage("Wrong number of arguments.");
-
- NDC.push("some context");
- test();
- }
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println("Usage: java " + SMTPMin.class.getName()
- + " configFile");
- System.exit(1);
- }
-
- static
- void init(String configFile) {
- PropertyConfigurator.configure(configFile);
- }
-
-
- static
- void test() {
- int i = 0;
- cat.debug( "Message " + i++);
- cat.debug("Message " + i++, new Exception("Just testing."));
- cat.info( "Message " + i++);
- cat.warn( "Message " + i++);
- cat.error( "Message " + i++);
- cat.log(Priority.FATAL, "Message " + i++);
- Category.shutdown();
- Thread.currentThread().getThreadGroup().list();
- }
-
-}
diff --git a/src/java/org/apache/log4j/net/test/SocketMin.java b/src/java/org/apache/log4j/net/test/SocketMin.java
deleted file mode 100644
index 15ab781eb6..0000000000
--- a/src/java/org/apache/log4j/net/test/SocketMin.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-package org.apache.log4j.net.test;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.net.SocketAppender;
-import org.apache.log4j.Priority;
-import org.apache.log4j.NDC;
-import java.io.InputStreamReader;
-
-public class SocketMin {
-
- static Category cat = Category.getInstance(SyslogMin.class.getName());
- static SocketAppender s;
-
- public
- static
- void main(String argv[]) {
- if(argv.length == 3)
- init(argv[0], argv[1]);
- else
- usage("Wrong number of arguments.");
-
- NDC.push("some context");
- if(argv[2].equals("true"))
- loop();
- else
- test();
-
- s.close();
- }
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println("Usage: java " + SocketMin.class
- + " host port true|false");
- System.exit(1);
- }
-
- static
- void init(String host, String portStr) {
- Category root = Category.getRoot();
- BasicConfigurator.configure();
- try {
- int port = Integer.parseInt(portStr);
- cat.info("Creating socket appender ("+host+","+port+").");
- s = new SocketAppender(host, port);
- s.setName("S");
- root.addAppender(s);
- }
- catch(java.lang.NumberFormatException e) {
- e.printStackTrace();
- usage("Could not interpret port number ["+ portStr +"].");
- }
- catch(Exception e) {
- System.err.println("Could not start!");
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- static
- void loop() {
- Category root = Category.getRoot();
- InputStreamReader in = new InputStreamReader(System.in);
- System.out.println("Type 'q' to quit");
- int i;
- int k = 0;
- while (true) {
- cat.debug("Message " + k++);
- cat.info("Message " + k++);
- cat.warn("Message " + k++);
- cat.error("Message " + k++, new Exception("Just testing"));
- try {i = in.read(); }
- catch(Exception e) { return; }
- if(i == -1) break;
- if(i == 'q') break;
- if(i == 'r') {
- System.out.println("Removing appender S");
- root.removeAppender("S");
- }
- }
- }
-
- static
- void test() {
- int i = 0;
- cat.debug( "Message " + i++);
- cat.info( "Message " + i++);
- cat.warn( "Message " + i++);
- cat.error( "Message " + i++);
- cat.log(Priority.FATAL, "Message " + i++);
- cat.debug("Message " + i++, new Exception("Just testing."));
- }
-}
diff --git a/src/java/org/apache/log4j/net/test/SyslogMin.java b/src/java/org/apache/log4j/net/test/SyslogMin.java
deleted file mode 100644
index 3c8f039777..0000000000
--- a/src/java/org/apache/log4j/net/test/SyslogMin.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-
-package org.apache.log4j.net.test;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.Priority;
-import org.apache.log4j.NDC;
-
-
-public class SyslogMin {
-
- static Category CAT = Category.getInstance(SyslogMin.class.getName());
-
- public
- static
- void main(String argv[]) {
-
- if(argv.length == 1) {
- ProgramInit(argv[0]);
- }
- else {
- Usage("Wrong number of arguments.");
- }
- test("someHost");
- }
-
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java " + SyslogMin.class + " configFile");
- System.exit(1);
- }
-
-
- static
- void ProgramInit(String configFile) {
- int port = 0;
- PropertyConfigurator.configure(configFile);
- }
-
- static
- void test(String host) {
- NDC.push(host);
- int i = 0;
- CAT.debug( "Message " + i++);
- CAT.info( "Message " + i++);
- CAT.warn( "Message " + i++);
- CAT.error( "Message " + i++);
- CAT.log(Priority.FATAL, "Message " + i++);
- CAT.debug("Message " + i++, new Exception("Just testing."));
- }
-}
diff --git a/src/java/org/apache/log4j/net/test/intermediarySocketServer.lcf b/src/java/org/apache/log4j/net/test/intermediarySocketServer.lcf
deleted file mode 100644
index af3a758de4..0000000000
--- a/src/java/org/apache/log4j/net/test/intermediarySocketServer.lcf
+++ /dev/null
@@ -1,23 +0,0 @@
-
-# ----------------------------------------------------------------------------
-# This config file is intended to be used by an intermediary SocketServer that
-# relays its log output to another SocketServer. This is used mostly to test
-# SocketServer cascading.
-# ----------------------------------------------------------------------------
-
-
-log4j.configDebug=true
-
-log4j.rootCategory=DEBUG, SOCKETSERV, CON
-
-log4j.category.org.apache.log4j.net=DEBUG
-log4j.appender.SOCKETSERV=org.apache.log4j.net.SocketAppender
-log4j.appender.SOCKETSERV.RemoteHost=localhost
-log4j.appender.SOCKETSERV.Port=15000
-log4j.appender.SOCKETSERV.layout=org.apache.log4j.PatternLayout
-log4j.appender.SOCKETSERV.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m%n
-
-
-log4j.appender.CON=org.apache.log4j.ConsoleAppender
-log4j.appender.CON.layout=org.apache.log4j.PatternLayout
-log4j.appender.CON.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m%n
\ No newline at end of file
diff --git a/src/java/org/apache/log4j/net/test/jms.lcf b/src/java/org/apache/log4j/net/test/jms.lcf
deleted file mode 100644
index a8e353594e..0000000000
--- a/src/java/org/apache/log4j/net/test/jms.lcf
+++ /dev/null
@@ -1,6 +0,0 @@
-
-log4j.rootCategory=DEBUG, A1
-log4j.configDebug=true
-log4j.appender.A1=org.apache.log4j.net.JMSAppender
-log4j.appender.A1.TopicBindingName=LOGBN
-log4j.appender.A1.TopicConnectionFactoryBindingName=TCFBN
diff --git a/src/java/org/apache/log4j/net/test/logging.lcf b/src/java/org/apache/log4j/net/test/logging.lcf
deleted file mode 100644
index e10dbc8c2c..0000000000
--- a/src/java/org/apache/log4j/net/test/logging.lcf
+++ /dev/null
@@ -1,9 +0,0 @@
-log4j.rootCategory= , testAppender
-log4j.configDebug=true
-log4j.appender.testAppender=org.apache.log4j.net.SyslogAppender
-log4j.appender.testAppender.SyslogHost=localhost
-log4j.appender.testAppender.Facility=LOCAL0
-log4j.appender.testAppender.FacilityPrinting=
-log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout
-log4j.appender.testAppender.layout.DateFormat=NULL
-log4j.appender.testAppender.layout.TimeZone=
diff --git a/src/java/org/apache/log4j/net/test/loop.lcf b/src/java/org/apache/log4j/net/test/loop.lcf
deleted file mode 100644
index 5913848788..0000000000
--- a/src/java/org/apache/log4j/net/test/loop.lcf
+++ /dev/null
@@ -1,9 +0,0 @@
-log4j.rootCategory= , A1
-log4j.configDebug=true
-log4j.appender.A1=org.apache.log4j.RollingFileAppender
-log4j.appender.A1.Append=true
-log4j.appender.A1.File=loop.log
-log4j.appender.A1.MaxFileSize=100KB
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%p [%t] - %m\n
-
diff --git a/src/java/org/apache/log4j/net/test/socketClient.lcf b/src/java/org/apache/log4j/net/test/socketClient.lcf
deleted file mode 100644
index 66cc5aaa78..0000000000
--- a/src/java/org/apache/log4j/net/test/socketClient.lcf
+++ /dev/null
@@ -1,20 +0,0 @@
-# -------------------------------------------------------------------------
-# This config file is intended to be used by a client wishing to log using
-# a SocketAppender to a SyslogServer or equivalent.
-# -------------------------------------------------------------------------
-
-log4j.configDebug=true
-
-log4j.rootCategory=DEBUG, A1, CON
-
-log4j.category.org.apache.log4j.net=DEBUG
-log4j.appender.A1=org.apache.log4j.net.SocketAppender
-log4j.appender.A1.RemoteHost=localhost
-log4j.appender.A1.Port=15000
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m%n
-
-
-log4j.appender.CON=org.apache.log4j.ConsoleAppender
-log4j.appender.CON.layout=org.apache.log4j.PatternLayout
-log4j.appender.CON.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m%n
\ No newline at end of file
diff --git a/src/java/org/apache/log4j/net/test/socketServer.lcf b/src/java/org/apache/log4j/net/test/socketServer.lcf
deleted file mode 100644
index 574d644489..0000000000
--- a/src/java/org/apache/log4j/net/test/socketServer.lcf
+++ /dev/null
@@ -1,12 +0,0 @@
-
-# -------------------------------------------------------------------
-# This config file is intended to be used by a SocketServer that logs
-# events received from various clients on the console.
-# -------------------------------------------------------------------
-
-log4j.rootCategory=DEBUG, A1
-log4j.category.org.apache.log4j.net=DEBUG
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m%n
-
diff --git a/src/java/org/apache/log4j/net/test/syslog.lcf b/src/java/org/apache/log4j/net/test/syslog.lcf
deleted file mode 100644
index 417ad6988e..0000000000
--- a/src/java/org/apache/log4j/net/test/syslog.lcf
+++ /dev/null
@@ -1,20 +0,0 @@
-
-# ------------------------------------------------+
-# Set the host variable to match your environment |
-# ------------------------------------------------+
-host=torino.qos.ch
-
-
-log4j.rootCategory=DEBUG, A1
-
-log4j.appender.A1=org.apache.log4j.net.SyslogAppender
-log4j.appender.A1.SyslogHost=${host}
-
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-
-# -----------------------------------------------------------------
-# The ConversionPattern should be terminated with a "\n" instead of
-# the usual "%n" as the syslog host is most probably a unix machine.
-# -----------------------------------------------------------------
-log4j.appender.A1.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m\n
-
diff --git a/src/java/org/apache/log4j/net/test/syslogMin b/src/java/org/apache/log4j/net/test/syslogMin
deleted file mode 100644
index ee0cea0ec9..0000000000
--- a/src/java/org/apache/log4j/net/test/syslogMin
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-# Read the .functions file
-. ../../test/.functions
-
-declare -i start=$1
-
-setPERL
-
- echo "log4j.rootCategory= , testAppender" > $LCF
- lecho "log4j.configDebug=true"
- lecho "log4j.appender.testAppender=org.apache.log4j.net.SyslogAppender"
- lecho "log4j.appender.testAppender.SyslogHost=localhost"
- lecho "log4j.appender.testAppender.Facility=LOCAL0"
- lecho "log4j.appender.testAppender.FacilityPrinting="
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
- lecho "log4j.appender.testAppender.layout.DateFormat=NULL"
- lecho "log4j.appender.testAppender.layout.TimeZone="
-
- java org.apache.log4j.net.test.SyslogMin $LCF
diff --git a/src/java/org/apache/log4j/nt/EventLogCategories.mc b/src/java/org/apache/log4j/nt/EventLogCategories.mc
deleted file mode 100644
index c896f54471..0000000000
--- a/src/java/org/apache/log4j/nt/EventLogCategories.mc
+++ /dev/null
@@ -1,24 +0,0 @@
-MessageId=0xC350
-Language=English
-Fatal
-.
-MessageId=0x9C40
-Language=English
-Error
-.
-MessageId=0x7530
-Language=English
-Warn
-.
-MessageId=0x4E20
-Language=English
-Info
-.
-MessageId=0x2710
-Language=English
-Debug
-.
-MessageId=0x1000
-Language=English
-%1
-.
diff --git a/src/java/org/apache/log4j/nt/make.bat b/src/java/org/apache/log4j/nt/make.bat
deleted file mode 100755
index ce73dd6d0d..0000000000
--- a/src/java/org/apache/log4j/nt/make.bat
+++ /dev/null
@@ -1,22 +0,0 @@
-@echo off
-
-REM This batch file is not intended for general use.
-
-javah org.apache.log4j.nt.NTEventLogAppender
-javah org.apache.log4j.Priority
-
-MC EventLogCategories.mc
-
-RC -r -fo EventLogCategories.res EventLogCategories.rc
-
-SET JDK=c:\java\jdk1.1.7B\
-rem SET JDK=c:\java\jdk1.3\
-
-@echo "Compiling"
-CL /nologo /I %JDK%\include /I %JDK%\include\win32 /MD /W3 /GX /O2 /FD /c /D "NDEBUG" -DWINVER=0x400 -D_DLL -DWIN32 /D "_WINDOWS" nteventlog.cpp
-
-REM
-
-@echo
-@echo "Linking"
-LINK /subsystem:windows /INCREMENTAL:NO /dll /out:"NTEventLogAppender.dll" nteventlog.OBJ advapi32.lib EventLogCategories.res
diff --git a/src/java/org/apache/log4j/nt/nteventlog.cpp b/src/java/org/apache/log4j/nt/nteventlog.cpp
deleted file mode 100644
index ba8453c161..0000000000
--- a/src/java/org/apache/log4j/nt/nteventlog.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-
-#ifndef NtEventLogAppender_h
-#define NtEventLogAppender_h
-#include "org_apache_log4j_Priority.h"
-#include "org_apache_log4j_nt_NTEventLogAppender.h"
-#include You should be able to see that anonymous string array
- construction is significatnly faster than string concatenation. The
- difference increases proportionally with the length of the strings
- to be concatanated.
-
- @author Ceki Gülcü
- */
-public class ConcatVsArray {
-
-
- static
- void Usage() {
- System.err.println("Usage: java org.apache.log4j.performance.ConcatVsArray " +
- "string1 string2 runLength\n" +
- " where runLength is an integer.");
- System.exit(1);
- }
-
- public static void main(String args[]) {
-
- if(args.length != 3) {
- Usage();
- }
-
- String s1 = args[0];
- String s2 = args[1];
- int runLength = 0;
- try {
- runLength = Integer.parseInt(args[2]);
- }
- catch(java.lang.NumberFormatException e) {
- System.err.println(e);
- Usage();
- }
-
- double micros;
-
- String[] sa;
- long before = new Date().getTime();
- for(int i = 0; i < runLength; i++) {
- sa = new String[]{s1, s2};
- }
- micros = (new Date().getTime() - before)*1000.0/runLength;
- System.out.println("The anonymous array loop took around " + micros + " microseconds.");
-
- String s;
- before = new Date().getTime();
- for(int i = 0; i < runLength; i++) {
- s = s1 + s2;
- }
- micros = (new Date().getTime() - before)*1000.0/runLength;
- System.out.println("The append loop took around " + micros + " microseconds.");
-
- }
-}
diff --git a/src/java/org/apache/log4j/performance/Logging.java b/src/java/org/apache/log4j/performance/Logging.java
deleted file mode 100644
index 8bf504daee..0000000000
--- a/src/java/org/apache/log4j/performance/Logging.java
+++ /dev/null
@@ -1,287 +0,0 @@
-// Copyright 1996-1999, International Business Machines
-// Corporation. All Rights Reserved.
-
-// Copyright 2000, Ceki Gulcu. All Rights Reserved.
-
-// See the LICENCE file for the terms of distribution.
-
-package org.apache.log4j.performance;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.xml.DOMConfigurator;
-
-import org.apache.log4j.NDC;
-import org.apache.log4j.performance.NOPWriter;
-
-
-/**
- Measure the performance of logging.
-
- Experimental results are listed below in units of
- micro-seconds. Measurements were done on a AMD Duron clocked
- at 800Mhz running Windows 2000 and Sun's 1.3 JDK.
-
- The results of the measurements (should) show that:
-
- On the other hand, had we interleaved logging operations with
- long blocking and non CPU-intensive operations, such as I/O,
- network access, sleeping threads, then the
- In a variant of this test, we have inserted a short sleep
- operation between every 10 log operations. When the total slept
- time is substracted, logging with the This application just prints the average time it took to log.
-
-
- */
- public static void main(String argv[]) {
-
- if(argv.length == 2)
- init(argv[0], argv[1], null, null);
- else if( argv.length == 4)
- init(argv[0], argv[1], argv[2], argv[3]);
- else
- Usage("Wrong number of arguments.");
-
-
- NDC.push("some context");
-
- double delta;
- String msg = "ABCDEGHIJKLMNOPQRSTUVWXYZabcdeghijklmnopqrstuvwxyz1234567890";
- if(delay <= 0)
- delta = NoDelayLoop(cat, msg);
- else
- delta = DelayedLoop(cat, msg);
-
- System.out.print((int)delta);
-
- Category.shutdown();
-
- }
-
- /**
- Program wide initialization method.
- */
- static
- void init(String configFile, String runLengthStr, String delayStr,
- String burstLenStr) {
- try {
- runLength = Integer.parseInt(runLengthStr);
- if(delayStr != null) {
- delay = Integer.parseInt(delayStr);
- }
- if(delayStr != null) {
- burstLen = Integer.parseInt(burstLenStr);
- DELAY_MULT = 1000/burstLen;
- }
- }
- catch(java.lang.NumberFormatException e) {
- e.printStackTrace();
- }
- DOMConfigurator.configure(configFile);
- }
-
- static
- double NoDelayLoop(Category category, String msg) {
- long before = System.currentTimeMillis();
- for(int i = 0; i < runLength; i++) {
- category.info(msg);
- }
- return ((System.currentTimeMillis() - before)*1000.0)/runLength;
- }
-
- static
- double DelayedLoop(Category category, String msg) {
- long before = System.currentTimeMillis();
- int j = 0;
- Thread currentThread = Thread.currentThread();
- for(int i = 0; i < runLength; i++) {
- category.info(msg);
- if(j++ == burstLen) {
- j = 0;
- try{currentThread.sleep(delay);}catch(Exception e){}
- }
-
- }
- double actualTime = ((System.currentTimeMillis()-before)*1000.0/runLength);
- System.out.println("actual time: "+actualTime);
- return (actualTime - delay*DELAY_MULT);
- }
-}
diff --git a/src/java/org/apache/log4j/performance/NOPWriter.java b/src/java/org/apache/log4j/performance/NOPWriter.java
deleted file mode 100644
index 9662360c38..0000000000
--- a/src/java/org/apache/log4j/performance/NOPWriter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 1996-1999, International Business Machines
-// Corporation. All Rights Reserved.
-
-package org.apache.log4j.performance;
-
-import java.io.Writer;
-import java.io.IOException;
-
-/**
- Extends {@link Writer} with methods that return immediately without
- doing anything. This class is used to measure the cost of
- constructing a log message but not actually writing to the
- OutputStream.
-
- @author Ceki Gülcü
-*/
-public class NOPWriter extends Writer {
-
- //public
- //NOPWriter() {
- //}
-
-
- public
- void write(char[] cbuf) throws IOException {}
-
- public
- void write(char[] cbuf, int off, int len) throws IOException {}
-
-
- public
- void write(int b) throws IOException {}
-
- public
- void write(String s) throws IOException {}
-
- public
- void write(String s, int off, int len) throws IOException {}
-
- public
- void flush() throws IOException {
- }
-
- public
- void close() throws IOException {
- System.err.println("Close called.");
- }
-}
diff --git a/src/java/org/apache/log4j/performance/NotLogging.java b/src/java/org/apache/log4j/performance/NotLogging.java
deleted file mode 100644
index 783655a022..0000000000
--- a/src/java/org/apache/log4j/performance/NotLogging.java
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright 1996-2000, International Business Machines
-// Corporation. All Rights Reserved.
-
-package org.apache.log4j.performance;
-
-
-import org.apache.log4j.Category;
-import org.apache.log4j.SimpleLayout;
-import org.apache.log4j.ConsoleAppender;
-
-import org.apache.log4j.Level;
-
-/**
- Measure the performance of evaluating whether to log or not to log,
- but not actually logging.
-
- This program takes two arguments, a string which should be
- "true" for testing shipped code performance and "false" for testing
- debug-enabled performance the second argument is the run length of
- the measurement loops.
-
- The results of the measurement (should) show that
-
-
-
- Package to measure the performance of the different log4j components.
-
-
- Setting the system property log4j.disable to DEBUG,
- INFO, WARN, ERROR or FATAL is equivalent to calling the {@link
- Hierarchy#disable} method with the corresponding level.
-
- @since 1.2 */
- // public static final String ENABLE_KEY = "log4j.enable";
-
-
- /**
- Special level value signifying inherited behaviour. The
- current value of this string constant is inherited.
- */
- public static final String INHERITED = "inherited";
-
-
-
- /**
- Interpret a resource pointed by a URL and set up log4j accordingly.
-
- The configuration is done relative to the See For example the {@link org.apache.log4j.net.SMTPAppender} sends
- an email when the {@link #isTriggeringEvent} method returns
- Package used to test the functionality of log4j.
-
- For example, if This approach enforces the independence of the XMLLayout and the
- appender where it is embedded.
-
- The If you are embedding this layout within an {@link
- org.apache.log4j.net.SMTPAppender} then make sure to set the
- LocationInfo option of that appender as well.
- */
- public
- void setLocationInfo(boolean flag) {
- locationInfo = flag;
- }
-
- /**
- Returns the current value of the LocationInfo option.
- */
- public
- boolean getLocationInfo() {
- return locationInfo;
- }
-
- public
- void activateOptions() {
- }
-
-
- /**
- Formats a {@link LoggingEvent} in conformance with the log4j.dtd. */
- public
- String format(LoggingEvent event) {
-
- // Reset working buffer. If the buffer is too large, then we need a new
- // one in order to avoid the penalty of creating a large array.
- if(buf.capacity() > UPPER_LIMIT) {
- buf = new StringBuffer(DEFAULT_SIZE);
- } else {
- buf.setLength(0);
- }
-
- // We yield to the \r\n heresy.
-
- buf.append(" Sample XML files sample1.xml
- and sample2.xml are provided.
-
-
- Note that the log4j.dtd is not in the local directory.
- It is found by the class loader.
-
- @author Ceki Gülcü
-
-*/
-public class XMLSample {
-
- static Category cat = Category.getInstance(XMLSample.class.getName());
-
- public
- static
- void main(String argv[]) {
-
- if(argv.length == 1)
- init(argv[0]);
- else
- Usage("Wrong number of arguments.");
- sample();
- }
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java " + XMLSample.class.getName() +
- "configFile");
- System.exit(1);
- }
-
- static
- void init(String configFile) {
- DOMConfigurator.configure(configFile);
- }
-
- static
- void sample() {
- int i = -1;
- Category root = Category.getRoot();
- cat.debug("Message " + ++i);
- cat.warn ("Message " + ++i);
- cat.error("Message " + ++i);
- Exception e = new Exception("Just testing");
- cat.debug("Message " + ++i, e);
- }
-}
diff --git a/src/java/org/apache/log4j/xml/examples/extension1.xml b/src/java/org/apache/log4j/xml/examples/extension1.xml
deleted file mode 100644
index af78d1ea2b..0000000000
--- a/src/java/org/apache/log4j/xml/examples/extension1.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
- Example usage of log4j with XML (including source code).
-
- This package's shows how log4j can be used with an XML
-configuration file.
-
- See source code of XMLSample.java showing how to
-configure with an XML file. Sample XML files
-sample1.xml,
-sample2.xml,
-sample3.xml,
-sample4.xml,
-sample5.xml are provided.
-
- For example, the following are all legal and will work as expected.
-
+ * This class has been deprecated and
+ * replaced by the {@link Logger} subclass. It
+ * will be kept around to preserve backward compatibility until mid
+ * 2003.
+ *
+ * For example, the following are all legal and will work as
+ * expected.
+ *
The first form is deprecated and should be avoided.
-
- There is absolutely no need for new client code to use or
- refer to the See the short manual for an
- introduction on this class.
-
- @author Ceki Gülcü
- @author Anders Kristensen */
+
+ * The first form is deprecated and should be avoided.
+ *
+ * There is absolutely no need for new client code to use or
+ * refer to the See the short manual for an
+ * introduction on this class.
+ *
+ * See the document entitled preparing
+ * for log4j 1.3 for a more detailed discussion.
+ *
+ * @author Ceki Gülcü
+ * @author Anders Kristensen
+ */
public class Category implements AppenderAttachable {
/**
@@ -77,9 +94,6 @@ public class Category implements AppenderAttachable {
//final Hierarchy defaultHierarchy = new Hierarchy(new
// RootCategory(Level.DEBUG));
-
- static int nooptimize;
-
/**
The name of this category.
*/
@@ -207,10 +221,10 @@ void callAppenders(LoggingEvent event) {
*/
synchronized
void closeNestedAppenders() {
- Enumeration enum = this.getAllAppenders();
- if(enum != null) {
- while(enum.hasMoreElements()) {
- Appender a = (Appender) enum.nextElement();
+ Enumeration enumeration = this.getAllAppenders();
+ if(enumeration != null) {
+ while(enumeration.hasMoreElements()) {
+ Appender a = (Appender) enumeration.nextElement();
if(a instanceof AppenderAttachable) {
a.close();
}
@@ -315,7 +329,7 @@ If the named category exists (in the default hierarchy) then it
@deprecated Please use {@link LogManager#exists} instead.
- @version 0.8.5 */
+ @since 0.8.5 */
public
static
Logger exists(String name) {
@@ -431,9 +445,10 @@ Level getEffectiveLevel() {
}
/**
-
- @deprecated Has been replaced by the {@link #getEffectiveLevel}
- method. */
+ *
+ * @deprecated Please use the the {@link #getEffectiveLevel} method
+ * instead.
+ * */
public
Priority getChainedPriority() {
for(Category c = this; c != null; c=c.parent) {
@@ -497,40 +512,20 @@ LoggerRepository getLoggerRepository() {
/**
- Retrieve a category with named as the The root category is always instantiated and available. It's
- name is "root".
-
- Nevertheless, calling {@link #getInstance
- Category.getInstance("root")} does not retrieve the root category
- but a category just under root named "root".
-
- Deprecated Use {@link Logger#getRootLogger()} instead.
+ * @deprecated Please use {@link Logger#getRootLogger()} instead.
*/
final
public
diff --git a/src/main/java/org/apache/log4j/CategoryKey.java b/src/main/java/org/apache/log4j/CategoryKey.java
new file mode 100644
index 0000000000..fe0fff7970
--- /dev/null
+++ b/src/main/java/org/apache/log4j/CategoryKey.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+/**
+ CategoryKey is a wrapper for String that apparently accellerated
+ hash table lookup in early JVM's.
+ @author Ceki Gülcü
+*/
+class CategoryKey {
+
+ String name;
+ int hashCache;
+
+ CategoryKey(String name) {
+ this.name = name;
+ hashCache = name.hashCode();
+ }
+
+ final
+ public
+ int hashCode() {
+ return hashCache;
+ }
+
+ final
+ public
+ boolean equals(Object rArg) {
+ if(this == rArg)
+ return true;
+
+ if(rArg != null && CategoryKey.class == rArg.getClass())
+ return name.equals(((CategoryKey)rArg ).name);
+ else
+ return false;
+ }
+}
diff --git a/src/main/java/org/apache/log4j/ConsoleAppender.java b/src/main/java/org/apache/log4j/ConsoleAppender.java
new file mode 100644
index 0000000000..b44fd5fddc
--- /dev/null
+++ b/src/main/java/org/apache/log4j/ConsoleAppender.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.log4j.helpers.LogLog;
+
+/**
+ * ConsoleAppender appends log events to Before actually logging, this method will check whether it is
- time to do a rollover. If it is, it will schedule the next
- rollover time and then rollover.
-
-
- */
- protected
- void subAppend(LoggingEvent event) {
+ * This method differentiates DailyRollingFileAppender from its
+ * super class.
+ *
+ * Before actually logging, this method will check whether it is
+ * time to do a rollover. If it is, it will schedule the next
+ * rollover time and then rollover.
+ * */
+ protected void subAppend(LoggingEvent event) {
long n = System.currentTimeMillis();
if (n >= nextCheck) {
now.setTime(n);
@@ -345,17 +361,12 @@ void subAppend(LoggingEvent event) {
}
/**
- RollingCalendar is a helper class to
- DailyRollingFileAppender. Using this class, it is easy to compute
- and access the next Millis().
-
- It subclasses the standard {@link GregorianCalendar}-object, to
- allow access to the protected function getTimeInMillis(), which it
- then exports.
-
- @author Eirik Lygre */
-
+ * RollingCalendar is a helper class to DailyRollingFileAppender.
+ * Given a periodicity type and the current time, it computes the
+ * start of the next interval.
+ * */
class RollingCalendar extends GregorianCalendar {
+ private static final long serialVersionUID = -3560331770601814177L;
int type = DailyRollingFileAppender.TOP_OF_TROUBLE;
@@ -371,13 +382,11 @@ void setType(int type) {
this.type = type;
}
- public
- long getNextCheckMillis(Date now) {
+ public long getNextCheckMillis(Date now) {
return getNextCheckDate(now).getTime();
}
- public
- Date getNextCheckDate(Date now) {
+ public Date getNextCheckDate(Date now) {
this.setTime(now);
switch(type) {
@@ -414,6 +423,7 @@ Date getNextCheckDate(Date now) {
case DailyRollingFileAppender.TOP_OF_WEEK:
this.set(Calendar.DAY_OF_WEEK, getFirstDayOfWeek());
this.set(Calendar.HOUR_OF_DAY, 0);
+ this.set(Calendar.MINUTE, 0);
this.set(Calendar.SECOND, 0);
this.set(Calendar.MILLISECOND, 0);
this.add(Calendar.WEEK_OF_YEAR, 1);
@@ -421,6 +431,7 @@ Date getNextCheckDate(Date now) {
case DailyRollingFileAppender.TOP_OF_MONTH:
this.set(Calendar.DATE, 1);
this.set(Calendar.HOUR_OF_DAY, 0);
+ this.set(Calendar.MINUTE, 0);
this.set(Calendar.SECOND, 0);
this.set(Calendar.MILLISECOND, 0);
this.add(Calendar.MONTH, 1);
diff --git a/src/main/java/org/apache/log4j/DefaultCategoryFactory.java b/src/main/java/org/apache/log4j/DefaultCategoryFactory.java
new file mode 100644
index 0000000000..c7bb0c4668
--- /dev/null
+++ b/src/main/java/org/apache/log4j/DefaultCategoryFactory.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+import org.apache.log4j.spi.LoggerFactory;
+
+class DefaultCategoryFactory implements LoggerFactory {
+
+ DefaultCategoryFactory() {
+ }
+
+ public
+ Logger makeNewLoggerInstance(String name) {
+ return new Logger(name);
+ }
+}
diff --git a/src/main/java/org/apache/log4j/Dispatcher.java b/src/main/java/org/apache/log4j/Dispatcher.java
new file mode 100644
index 0000000000..e879ff0abf
--- /dev/null
+++ b/src/main/java/org/apache/log4j/Dispatcher.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+import org.apache.log4j.helpers.AppenderAttachableImpl;
+import org.apache.log4j.spi.LoggingEvent;
+
+
+/**
+ * Obsolete AsyncAppender dispatcher provided for compatibility only.
+ *
+ * @deprecated Since 1.3.
+ */
+class Dispatcher extends Thread {
+ /**
+ * @deprecated
+ */
+ private org.apache.log4j.helpers.BoundedFIFO bf;
+ private AppenderAttachableImpl aai;
+ private boolean interrupted = false;
+ AsyncAppender container;
+
+ /**
+ *
+ * @param bf
+ * @param container
+ * @deprecated
+ */
+ Dispatcher(org.apache.log4j.helpers.BoundedFIFO bf, AsyncAppender container) {
+ this.bf = bf;
+ this.container = container;
+ this.aai = container.aai;
+
+ // It is the user's responsibility to close appenders before
+ // exiting.
+ this.setDaemon(true);
+
+ // set the dispatcher priority to lowest possible value
+ this.setPriority(Thread.MIN_PRIORITY);
+ this.setName("Dispatcher-" + getName());
+
+ // set the dispatcher priority to MIN_PRIORITY plus or minus 2
+ // depending on the direction of MIN to MAX_PRIORITY.
+ //+ (Thread.MAX_PRIORITY > Thread.MIN_PRIORITY ? 1 : -1)*2);
+ }
+
+ void close() {
+ synchronized (bf) {
+ interrupted = true;
+
+ // We have a waiting dispacther if and only if bf.length is
+ // zero. In that case, we need to give it a death kiss.
+ if (bf.length() == 0) {
+ bf.notify();
+ }
+ }
+ }
+
+ /**
+ * The dispatching strategy is to wait until there are events in the buffer
+ * to process. After having processed an event, we release the monitor
+ * (variable bf) so that new events can be placed in the buffer, instead of
+ * keeping the monitor and processing the remaining events in the buffer.
+ *
+ *
+ * Other approaches might yield better results.
+ * Support for Support for This option is meaningful only if the FileAppender opens the
- file.
- */
+ /** Controls file truncatation. The default value for this variable
+ * is This option is meaningful only if the FileAppender opens the
+ * file.
+ */
protected boolean fileAppend = true;
/**
@@ -49,7 +61,8 @@ public class FileAppender extends WriterAppender {
protected boolean bufferedIO = false;
/**
- How big should the IO buffer be? Default is 8K. */
+ * Determines the size of IO buffer be. Default is 8K.
+ */
protected int bufferSize = 8*1024;
@@ -269,7 +282,31 @@ void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize
}
reset();
- Writer fw = createWriter(new FileOutputStream(fileName, append));
+ FileOutputStream ostream = null;
+ try {
+ //
+ // attempt to create file
+ //
+ ostream = new FileOutputStream(fileName, append);
+ } catch(FileNotFoundException ex) {
+ //
+ // if parent directory does not exist then
+ // attempt to create it and try to create file
+ // see bug 9150
+ //
+ String parentName = new File(fileName).getParent();
+ if (parentName != null) {
+ File parentDir = new File(parentName);
+ if(!parentDir.exists() && parentDir.mkdirs()) {
+ ostream = new FileOutputStream(fileName, append);
+ } else {
+ throw ex;
+ }
+ } else {
+ throw ex;
+ }
+ }
+ Writer fw = createWriter(ostream);
if(bufferedIO) {
fw = new BufferedWriter(fw, bufferSize);
}
diff --git a/src/java/org/apache/log4j/HTMLLayout.java b/src/main/java/org/apache/log4j/HTMLLayout.java
similarity index 79%
rename from src/java/org/apache/log4j/HTMLLayout.java
rename to src/main/java/org/apache/log4j/HTMLLayout.java
index 013b7c59e4..f7020cf25d 100644
--- a/src/java/org/apache/log4j/HTMLLayout.java
+++ b/src/main/java/org/apache/log4j/HTMLLayout.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j;
@@ -12,9 +22,14 @@
import org.apache.log4j.helpers.Transform;
/**
- This layout outputs events in a HTML table.
-
- @author Ceki Gülcü
+ * This layout outputs events in a HTML table.
+ *
+ * Appenders using this layout should have their encoding
+ * set to UTF-8 or UTF-16, otherwise events containing
+ * non ASCII characters could result in corrupted
+ * log files.
+ *
+ * @author Ceki Gülcü
*/
public class HTMLLayout extends Layout {
@@ -122,30 +137,32 @@ String format(LoggingEvent event) {
sbuf.append(Layout.LINE_SEP + " See also the full description of default
- intialization procedure.
-
- @since 0.8.5 */
- static public final String DEFAULT_CONFIGURATION_FILE = "log4j.properties";
-
- /**
- This string constant is set to log4j.configuration.
-
- It corresponds to name of a system property that, if set,
- specifies the name of the resource containing the properties file
- or {@link URL} with which log4j should configure itself. See
- {@link OptionConverter#selectAndConfigure} for more detailed
- information on the processing of this option.
-
- Setting the log4j.configuration system property
- overrides the default search for the file log4j.properties.
-
- Note that all property keys are case sensitive.
-
- See also the full description of default
- intialization procedure.
-
- @since 1.0 */
- static final public String DEFAULT_CONFIGURATION_KEY="log4j.configuration";
-
- /**
- This string constant is set to log4j.configuratorClass.
-
- It corresponds to name of a system property that, if set,
- specifies the class name to use to automatically configure
- log4j. See {@link OptionConverter#selectAndConfigure} for more
- detailed information on the processing of this option.
-
- Setting the log4j.configuration system property
- overrides the default search for the file log4j.properties.
-
- Note that all property keys are case sensitive.
-
- See also the full description of default
- intialization procedure.
+ * @deprecated This variable is for internal use only. It will
+ * become package protected in future versions.
+ * */
+ static public final String DEFAULT_CONFIGURATION_FILE = "log4j.properties";
+
+ static final String DEFAULT_XML_CONFIGURATION_FILE = "log4j.xml";
- @since 1.2 */
- static final public String CONFIGURATOR_CLASS_KEY="log4j.configuratorClass";
-
/**
- Setting the system property log4j.defaultInitOverride to
- "true" or any other value than "false" will skip default
- configuration process.
-
- The current value of the DEFAULT_INIT_OVERRIDE_KEY string
- constant is log4j.defaultInitOverride.
-
- See also the full description of default
- intialization procedure.
+ * @deprecated This variable is for internal use only. It will
+ * become private in future versions.
+ * */
+ static final public String DEFAULT_CONFIGURATION_KEY="log4j.configuration";
- Note that all property keys are case sensitive.
+ /**
+ * @deprecated This variable is for internal use only. It will
+ * become private in future versions.
+ * */
+ static final public String CONFIGURATOR_CLASS_KEY="log4j.configuratorClass";
- @since 0.8.5 */
+ /**
+ * @deprecated This variable is for internal use only. It will
+ * become private in future versions.
+ */
public static final String DEFAULT_INIT_OVERRIDE_KEY =
"log4j.defaultInitOverride";
@@ -110,42 +76,54 @@ specifies the class name to use to automatically configure
static {
// By default we use a DefaultRepositorySelector which always returns 'h'.
- Hierarchy h = new Hierarchy(new RootCategory((Level) Level.DEBUG));
+ Hierarchy h = new Hierarchy(new RootLogger((Level) Level.DEBUG));
repositorySelector = new DefaultRepositorySelector(h);
/** Search for the properties file log4j.properties in the CLASSPATH. */
String override =OptionConverter.getSystemProperty(DEFAULT_INIT_OVERRIDE_KEY,
null);
- // if there is no default init override, them get the resource
+ // if there is no default init override, then get the resource
// specified by the user or the default config file.
if(override == null || "false".equalsIgnoreCase(override)) {
- String resource = OptionConverter.getSystemProperty(
- DEFAULT_CONFIGURATION_KEY,
- DEFAULT_CONFIGURATION_FILE);
+
+ String configurationOptionStr = OptionConverter.getSystemProperty(
+ DEFAULT_CONFIGURATION_KEY,
+ null);
String configuratorClassName = OptionConverter.getSystemProperty(
CONFIGURATOR_CLASS_KEY,
null);
URL url = null;
- try {
- // so, resource is not a URL:
- // attempt to get the resource from the class path
- url = new URL(resource);
- } catch (MalformedURLException ex) {
- url = Loader.getResource(resource);
- }
+
+ // if the user has not specified the log4j.configuration
+ // property, we search first for the file "log4j.xml" and then
+ // "log4j.properties"
+ if(configurationOptionStr == null) {
+ url = Loader.getResource(DEFAULT_XML_CONFIGURATION_FILE);
+ if(url == null) {
+ url = Loader.getResource(DEFAULT_CONFIGURATION_FILE);
+ }
+ } else {
+ try {
+ url = new URL(configurationOptionStr);
+ } catch (MalformedURLException ex) {
+ // so, resource is not a URL:
+ // attempt to get the resource from the class path
+ url = Loader.getResource(configurationOptionStr);
+ }
+ }
// If we have a non-null url, then delegate the rest of the
// configuration to the OptionConverter.selectAndConfigure
// method.
if(url != null) {
- LogLog.debug("Using URL ["+url+"] for automatic log4j configuration.");
+ LogLog.debug("Using URL ["+url+"] for automatic log4j configuration.");
OptionConverter.selectAndConfigure(url, configuratorClassName,
LogManager.getLoggerRepository());
} else {
- LogLog.debug("Could not find resource: ["+resource+"].");
+ LogLog.debug("Could not find resource: ["+configurationOptionStr+"].");
}
}
}
diff --git a/src/main/java/org/apache/log4j/Logger.java b/src/main/java/org/apache/log4j/Logger.java
new file mode 100644
index 0000000000..aa4af73426
--- /dev/null
+++ b/src/main/java/org/apache/log4j/Logger.java
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+import org.apache.log4j.spi.LoggerFactory;
+import org.apache.log4j.Level;
+
+
+/**
+ This is the central class in the log4j package. Most logging
+ operations, except configuration, are done through this class.
+
+ @since log4j 1.2
+
+ @author Ceki Gülcü */
+public class Logger extends Category {
+
+ /**
+ The fully qualified name of the Logger class. See also the
+ getFQCN method. */
+ private static final String FQCN = Logger.class.getName();
+
+
+ protected
+ Logger(String name) {
+ super(name);
+ }
+
+ /**
+ Log a message object with the {@link Level#FINE FINE} level which
+ is just an alias for the {@link Level#DEBUG DEBUG} level.
+
+ This method first checks if this category is WARNING Note that passing a {@link Throwable} to this
+ method will print the name of the See {@link #fine(Object)} form for more detailed information.
+
+ @param message the message object to log.
+ @param t the exception to log, including its stack trace. */
+ //public
+ //void fine(Object message, Throwable t) {
+ // if(repository.isDisabled(Level.DEBUG_INT))
+ // return;
+ // if(Level.DEBUG.isGreaterOrEqual(this.getChainedLevel()))
+ // forcedLog(FQCN, Level.FINE, message, t);
+ //}
+
+ /**
+ * Retrieve a logger named according to the value of the
+ * By default, loggers do not have a set level but inherit it
+ * from their neareast ancestor with a set level. This is one of the
+ * central features of log4j.
+ *
+ * @param name The name of the logger to retrieve.
+ */
+ static
+ public
+ Logger getLogger(String name) {
+ return LogManager.getLogger(name);
+ }
+
+ /**
+ * Shorthand for
+ * The {@link #getName Logger.getName()} method for the root logger always returns
+ * stirng value: "root". However, calling
+ *
+ * In other words, calling this method is the only way to retrieve the
+ * root logger.
+ */
+ public
+ static
+ Logger getRootLogger() {
+ return LogManager.getRootLogger();
+ }
+
+ /**
+ Like {@link #getLogger(String)} except that the type of logger
+ instantiated depends on the type returned by the {@link
+ LoggerFactory#makeNewLoggerInstance} method of the
+ This method is intended to be used by sub-classes.
+
+ @param name The name of the logger to retrieve.
+
+ @param factory A {@link LoggerFactory} implementation that will
+ actually create a new Instance.
+
+ @since 0.8.5 */
+ public
+ static
+ Logger getLogger(String name, LoggerFactory factory) {
+ return LogManager.getLogger(name, factory);
+ }
+
+ /**
+ * Log a message object with the {@link org.apache.log4j.Level#TRACE TRACE} level.
+ *
+ * @param message the message object to log.
+ * @see #debug(Object) for an explanation of the logic applied.
+ * @since 1.2.12
+ */
+ public void trace(Object message) {
+ if (repository.isDisabled(Level.TRACE_INT)) {
+ return;
+ }
+
+ if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) {
+ forcedLog(FQCN, Level.TRACE, message, null);
+ }
+ }
+
+ /**
+ * Log a message object with the
+ * See {@link #debug(Object)} form for more detailed information.
+ * It is sometimes useful to see how log4j is reading configuration
@@ -100,7 +108,7 @@ public class PropertyConfigurator implements Configurator {
/**
Read configuration from a file. The existing configuration is
not cleared nor reset. If you require a different behavior,
- then call {@link BasicConfigurator#resetConfiguration
+ then call {@link LogManager#resetConfiguration
resetConfiguration} method before calling
The level value can consist of the string values OFF, FATAL,
- ERROR, WARN, INFO, DEBUG, ALL or a custom level value. A
+ ERROR, WARN, INFO, DEBUG, ALL or a custom level value. A
custom level value can be specified in the form
level#classname. By default the repository-wide threshold is set
to the lowest possible value, namely the level For non-root categories the syntax is almost the same:
The meaning of the optional level value is discussed above
@@ -187,9 +195,10 @@ public class PropertyConfigurator implements Configurator {
named logger remains untouched.
By default categories inherit their level from the
- hierarchy. However, if you set the level of a logger and
- later decide that that logger should inherit its level, then
- you should specify INHERITED as the value for the level value.
+ hierarchy. However, if you set the level of a logger and later
+ decide that that logger should inherit its level, then you should
+ specify INHERITED as the value for the level value. NULL is a
+ synonym for INHERITED.
Similar to the root logger syntax, each appenderName
(separated by commas) will be attached to the named logger.
@@ -292,15 +301,24 @@ public class PropertyConfigurator implements Configurator {
public
void doConfigure(String configFileName, LoggerRepository hierarchy) {
Properties props = new Properties();
+ FileInputStream istream = null;
try {
- FileInputStream istream = new FileInputStream(configFileName);
+ istream = new FileInputStream(configFileName);
props.load(istream);
istream.close();
}
- catch (IOException e) {
+ catch (Exception e) {
LogLog.error("Could not read configuration file ["+configFileName+"].", e);
LogLog.error("Ignoring configuration file [" + configFileName+"].");
return;
+ } finally {
+ if(istream != null) {
+ try {
+ istream.close();
+ } catch(Throwable ignore) {
+ }
+
+ }
}
// If we reach here, then the config file is alright.
doConfigure(props, hierarchy);
@@ -385,7 +403,7 @@ void doConfigure(Properties properties, LoggerRepository hierarchy) {
String value = properties.getProperty(LogLog.DEBUG_KEY);
if(value == null) {
- value = properties.getProperty(LogLog.CONFIG_DEBUG_KEY);
+ value = properties.getProperty("log4j.configDebug");
if(value != null)
LogLog.warn("[log4j.configDebug] is deprecated. Use [log4j.debug] instead.");
}
@@ -419,15 +437,25 @@ void doConfigure(Properties properties, LoggerRepository hierarchy) {
void doConfigure(java.net.URL configURL, LoggerRepository hierarchy) {
Properties props = new Properties();
LogLog.debug("Reading configuration from URL " + configURL);
+ InputStream istream = null;
try {
- props.load(configURL.openStream());
+ istream = configURL.openStream();
+ props.load(istream);
}
- catch (java.io.IOException e) {
+ catch (Exception e) {
LogLog.error("Could not read configuration file from URL [" + configURL
+ "].", e);
LogLog.error("Ignoring configuration file [" + configURL +"].");
return;
}
+ finally {
+ if (istream != null) {
+ try {
+ istream.close();
+ } catch(Exception ignore) {
+ }
+ }
+ }
doConfigure(props, hierarchy);
}
@@ -507,9 +535,9 @@ void configureRootCategory(Properties props, LoggerRepository hierarchy) {
*/
protected
void parseCatsAndRenderers(Properties props, LoggerRepository hierarchy) {
- Enumeration enum = props.propertyNames();
- while(enum.hasMoreElements()) {
- String key = (String) enum.nextElement();
+ Enumeration enumeration = props.propertyNames();
+ while(enumeration.hasMoreElements()) {
+ String key = (String) enumeration.nextElement();
if(key.startsWith(CATEGORY_PREFIX) || key.startsWith(LOGGER_PREFIX)) {
String loggerName = null;
if(key.startsWith(CATEGORY_PREFIX)) {
@@ -576,9 +604,13 @@ void parseCategory(Properties props, Logger logger, String optionKey,
// If the level value is inherited, set category level value to
// null. We also check that the user has not specified inherited for the
// root category.
- if(levelStr.equalsIgnoreCase(INHERITED) &&
- !loggerName.equals(INTERNAL_ROOT_NAME)) {
- logger.setLevel(null);
+ if(INHERITED.equalsIgnoreCase(levelStr) ||
+ NULL.equalsIgnoreCase(levelStr)) {
+ if(loggerName.equals(INTERNAL_ROOT_NAME)) {
+ LogLog.warn("The root logger cannot be set to null.");
+ } else {
+ logger.setLevel(null);
+ }
} else {
logger.setLevel(OptionConverter.toLevel(levelStr, (Level) Level.DEBUG));
}
diff --git a/src/main/java/org/apache/log4j/ProvisionNode.java b/src/main/java/org/apache/log4j/ProvisionNode.java
new file mode 100644
index 0000000000..f1126822a1
--- /dev/null
+++ b/src/main/java/org/apache/log4j/ProvisionNode.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+import java.util.Vector;
+
+class ProvisionNode extends Vector {
+ private static final long serialVersionUID = -4479121426311014469L;
+
+ ProvisionNode(Logger logger) {
+ super();
+ this.addElement(logger);
+ }
+}
diff --git a/src/java/org/apache/log4j/RollingFileAppender.java b/src/main/java/org/apache/log4j/RollingFileAppender.java
similarity index 75%
rename from src/java/org/apache/log4j/RollingFileAppender.java
rename to src/main/java/org/apache/log4j/RollingFileAppender.java
index 89f680eb92..4ad42e9285 100644
--- a/src/java/org/apache/log4j/RollingFileAppender.java
+++ b/src/main/java/org/apache/log4j/RollingFileAppender.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
@@ -37,6 +47,8 @@ public class RollingFileAppender extends FileAppender {
*/
protected int maxBackupIndex = 1;
+ private long nextRollover = 0;
+
/**
The default constructor simply calls its {@link
FileAppender#FileAppender parents constructor}. */
@@ -109,26 +121,34 @@ void rollOver() {
File target;
File file;
- LogLog.debug("rolling over count=" + ((CountingQuietWriter) qw).getCount());
+ if (qw != null) {
+ long size = ((CountingQuietWriter) qw).getCount();
+ LogLog.debug("rolling over count=" + size);
+ // if operation fails, do not roll again until
+ // maxFileSize more bytes are written
+ nextRollover = size + maxFileSize;
+ }
LogLog.debug("maxBackupIndex="+maxBackupIndex);
+ boolean renameSucceeded = true;
// If maxBackups <= 0, then there is no file renaming to be done.
if(maxBackupIndex > 0) {
// Delete the oldest file, to keep Windows happy.
file = new File(fileName + '.' + maxBackupIndex);
if (file.exists())
- file.delete();
+ renameSucceeded = file.delete();
// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
- for (int i = maxBackupIndex - 1; i >= 1; i--) {
+ for (int i = maxBackupIndex - 1; i >= 1 && renameSucceeded; i--) {
file = new File(fileName + "." + i);
if (file.exists()) {
target = new File(fileName + '.' + (i + 1));
LogLog.debug("Renaming file " + file + " to " + target);
- file.renameTo(target);
+ renameSucceeded = file.renameTo(target);
}
}
+ if(renameSucceeded) {
// Rename fileName to fileName.1
target = new File(fileName + "." + 1);
@@ -136,17 +156,35 @@ void rollOver() {
file = new File(fileName);
LogLog.debug("Renaming file " + file + " to " + target);
- file.renameTo(target);
+ renameSucceeded = file.renameTo(target);
+ //
+ // if file rename failed, reopen file with append = true
+ //
+ if (!renameSucceeded) {
+ try {
+ this.setFile(fileName, true, bufferedIO, bufferSize);
+ }
+ catch(IOException e) {
+ LogLog.error("setFile("+fileName+", true) call failed.", e);
+ }
+ }
+ }
}
+ //
+ // if all renames were successful, then
+ //
+ if (renameSucceeded) {
try {
// This will also close the file. This is OK since multiple
// close operations are safe.
this.setFile(fileName, false, bufferedIO, bufferSize);
+ nextRollover = 0;
}
catch(IOException e) {
LogLog.error("setFile("+fileName+", false) call failed.", e);
}
+ }
}
public
@@ -223,8 +261,11 @@ void setQWForFiles(Writer writer) {
protected
void subAppend(LoggingEvent event) {
super.subAppend(event);
- if((fileName != null) &&
- ((CountingQuietWriter) qw).getCount() >= maxFileSize)
- this.rollOver();
+ if(fileName != null && qw != null) {
+ long size = ((CountingQuietWriter) qw).getCount();
+ if (size >= maxFileSize && size >= nextRollover) {
+ rollOver();
+ }
+ }
}
}
diff --git a/src/java/org/apache/log4j/SimpleLayout.java b/src/main/java/org/apache/log4j/SimpleLayout.java
similarity index 61%
rename from src/java/org/apache/log4j/SimpleLayout.java
rename to src/main/java/org/apache/log4j/SimpleLayout.java
index 565ca5479b..5699661ba6 100644
--- a/src/java/org/apache/log4j/SimpleLayout.java
+++ b/src/main/java/org/apache/log4j/SimpleLayout.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j;
@@ -49,7 +58,7 @@ void activateOptions() {
String format(LoggingEvent event) {
sbuf.setLength(0);
- sbuf.append(event.level.toString());
+ sbuf.append(event.getLevel().toString());
sbuf.append(" - ");
sbuf.append(event.getRenderedMessage());
sbuf.append(LINE_SEP);
diff --git a/src/java/org/apache/log4j/TTCCLayout.java b/src/main/java/org/apache/log4j/TTCCLayout.java
similarity index 86%
rename from src/java/org/apache/log4j/TTCCLayout.java
rename to src/main/java/org/apache/log4j/TTCCLayout.java
index 5ce94e60b2..3b0e98f967 100644
--- a/src/java/org/apache/log4j/TTCCLayout.java
+++ b/src/main/java/org/apache/log4j/TTCCLayout.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
// Contributors: Christopher Williams
@@ -157,9 +166,7 @@ boolean getContextPrinting() {
Time, thread, category and diagnostic context are printed
depending on options.
- @param category
- @param level
- @param message
+ @param event The event to format
*/
public
@@ -175,11 +182,11 @@ String format(LoggingEvent event) {
buf.append(event.getThreadName());
buf.append("] ");
}
- buf.append(event.level.toString());
+ buf.append(event.getLevel().toString());
buf.append(' ');
if(this.categoryPrefixing) {
- buf.append(event.categoryName);
+ buf.append(event.getLoggerName());
buf.append(' ');
}
diff --git a/src/java/org/apache/log4j/WriterAppender.java b/src/main/java/org/apache/log4j/WriterAppender.java
similarity index 86%
rename from src/java/org/apache/log4j/WriterAppender.java
rename to src/main/java/org/apache/log4j/WriterAppender.java
index 50b33f4a02..5e197d9cf7 100644
--- a/src/java/org/apache/log4j/WriterAppender.java
+++ b/src/main/java/org/apache/log4j/WriterAppender.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j;
@@ -45,7 +55,7 @@ public class WriterAppender extends AppenderSkeleton {
protected boolean immediateFlush = true;
/**
- The encoding to use when opening an InputStream. The
+ The encoding to use when writing. The
WARNING: Logging to an unopened Writer will fail.
@param writer An already opened Writer. */
- public
- synchronized
- void setWriter(Writer writer) {
+ public synchronized void setWriter(Writer writer) {
reset();
this.qw = new QuietWriter(writer, errorHandler);
//this.tp = new TracerPrintWriter(qw);
diff --git a/src/java/org/apache/log4j/chainsaw/ControlPanel.java b/src/main/java/org/apache/log4j/chainsaw/ControlPanel.java
similarity index 83%
rename from src/java/org/apache/log4j/chainsaw/ControlPanel.java
rename to src/main/java/org/apache/log4j/chainsaw/ControlPanel.java
index 741edecad9..53b0b1b5fa 100644
--- a/src/java/org/apache/log4j/chainsaw/ControlPanel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/ControlPanel.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.chainsaw;
import java.awt.GridBagConstraints;
@@ -18,8 +28,9 @@
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
+import org.apache.log4j.Level;
/**
* Represents the controls for filtering, pausing, exiting, etc.
@@ -28,8 +39,8 @@
*/
class ControlPanel extends JPanel {
/** use the log messages **/
- private static final Category LOG =
- Category.getInstance(ControlPanel.class);
+ private static final Logger LOG =
+ Logger.getLogger(ControlPanel.class);
/**
* Creates a new Refer to the resource WARNING: This version of JDBCAppender
+ is very likely to be completely replaced in the future. Moreoever,
+ it does not log exceptions.
+ The JDBCAppender provides for sending log events to a database.
+
+
Each append call adds to an JMS {@link Topic topics} and {@link TopicConnectionFactory topic
+ * connection factories} are administered objects that are retrieved
+ * using JNDI messaging which in turn requires the retreival of a JNDI
+ * {@link Context}.
+
+ * There are two common methods for retrieving a JNDI {@link
+ * Context}. If a file resource named jndi.properties is
+ * available to the JNDI API, it will use the information found
+ * therein to retrieve an initial JNDI context. To obtain an initial
+ * context, your code will simply call:
+
+ Calling the no-argument In the second approach, several predetermined properties are set
+ * and these properties are passed to the To connect to the the naming service of Weblogic application
+ * server one would write:
+
+ Other JMS providers will obviously require different values.
+ *
+ * The initial JNDI context can be obtained by calling the
+ * no-argument See also {@link #setProviderURL(String)}.
+ * */
+ public void setInitialContextFactoryName(String initialContextFactoryName) {
+ this.initialContextFactoryName = initialContextFactoryName;
+ }
+
+ public String getProviderURL() {
+ return providerURL;
+ }
+
+ public void setProviderURL(String providerURL) {
+ this.providerURL = providerURL;
+ }
+
+ String getURLPkgPrefixes( ) {
+ return urlPkgPrefixes;
+ }
+
+ public void setURLPkgPrefixes(String urlPkgPrefixes ) {
+ this.urlPkgPrefixes = urlPkgPrefixes;
+ }
+
+ public String getSecurityCredentials() {
+ return securityCredentials;
+ }
+
+ public void setSecurityCredentials(String securityCredentials) {
+ this.securityCredentials = securityCredentials;
+ }
+
+
+ public String getSecurityPrincipalName() {
+ return securityPrincipalName;
+ }
+
+ public void setSecurityPrincipalName(String securityPrincipalName) {
+ this.securityPrincipalName = securityPrincipalName;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ /**
+ * The user name to use when {@link
+ * TopicConnectionFactory#createTopicConnection(String, String)
+ * creating a topic session}. If you set this option, you should
+ * also set the Password option. See {@link
+ * #setPassword(String)}.
+ * */
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * The paswword to use when creating a topic session.
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+
+ /**
+ If true, the information sent to the remote subscriber will
+ include caller's location information. By default no location
+ information is sent to the subscriber. */
+ public void setLocationInfo(boolean locationInfo) {
+ this.locationInfo = locationInfo;
+ }
+
+ /**
+ * Returns the TopicConnection used for this appender. Only valid after
+ * activateOptions() method has been invoked.
+ */
+ protected TopicConnection getTopicConnection() {
+ return topicConnection;
+ }
+
+ /**
+ * Returns the TopicSession used for this appender. Only valid after
+ * activateOptions() method has been invoked.
+ */
+ protected TopicSession getTopicSession() {
+ return topicSession;
+ }
+
+ /**
+ * Returns the TopicPublisher used for this appender. Only valid after
+ * activateOptions() method has been invoked.
+ */
+ protected TopicPublisher getTopicPublisher() {
+ return topicPublisher;
+ }
+
+ /**
+ * The JMSAppender sends serialized events and consequently does not
+ * require a layout.
+ */
+ public boolean requiresLayout() {
+ return false;
+ }
+}
diff --git a/src/main/java/org/apache/log4j/net/JMSSink.java b/src/main/java/org/apache/log4j/net/JMSSink.java
new file mode 100644
index 0000000000..78d657efbd
--- /dev/null
+++ b/src/main/java/org/apache/log4j/net/JMSSink.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.net;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.xml.DOMConfigurator;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicSession;
+import javax.jms.TopicSubscriber;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * A simple application that consumes logging events sent by a {@link
+ * JMSAppender}.
+ *
+ *
+ * @author Ceki Gülcü
+ * */
+public class JMSSink implements javax.jms.MessageListener {
+
+ static Logger logger = Logger.getLogger(JMSSink.class);
+
+ static public void main(String[] args) throws Exception {
+ if(args.length != 5) {
+ usage("Wrong number of arguments.");
+ }
+
+ String tcfBindingName = args[0];
+ String topicBindingName = args[1];
+ String username = args[2];
+ String password = args[3];
+
+
+ String configFile = args[4];
+
+ if(configFile.endsWith(".xml")) {
+ DOMConfigurator.configure(configFile);
+ } else {
+ PropertyConfigurator.configure(configFile);
+ }
+
+ new JMSSink(tcfBindingName, topicBindingName, username, password);
+
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ // Loop until the word "exit" is typed
+ System.out.println("Type \"exit\" to quit JMSSink.");
+ while(true){
+ String s = stdin.readLine( );
+ if (s.equalsIgnoreCase("exit")) {
+ System.out.println("Exiting. Kill the application if it does not exit "
+ + "due to daemon threads.");
+ return;
+ }
+ }
+ }
+
+ public JMSSink( String tcfBindingName, String topicBindingName, String username,
+ String password) {
+
+ try {
+ Context ctx = new InitialContext();
+ TopicConnectionFactory topicConnectionFactory;
+ topicConnectionFactory = (TopicConnectionFactory) lookup(ctx,
+ tcfBindingName);
+
+ TopicConnection topicConnection =
+ topicConnectionFactory.createTopicConnection(username,
+ password);
+ topicConnection.start();
+
+ TopicSession topicSession = topicConnection.createTopicSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+
+ Topic topic = (Topic)ctx.lookup(topicBindingName);
+
+ TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic);
+
+ topicSubscriber.setMessageListener(this);
+
+ } catch(Exception e) {
+ logger.error("Could not read JMS message.", e);
+ }
+ }
+
+ public void onMessage(javax.jms.Message message) {
+ LoggingEvent event;
+ Logger remoteLogger;
+
+ try {
+ if(message instanceof ObjectMessage) {
+ ObjectMessage objectMessage = (ObjectMessage) message;
+ event = (LoggingEvent) objectMessage.getObject();
+ remoteLogger = Logger.getLogger(event.getLoggerName());
+ remoteLogger.callAppenders(event);
+ } else {
+ logger.warn("Received message is of type "+message.getJMSType()
+ +", was expecting ObjectMessage.");
+ }
+ } catch(JMSException jmse) {
+ logger.error("Exception thrown while processing incoming message.",
+ jmse);
+ }
+ }
+
+
+ protected static Object lookup(Context ctx, String name) throws NamingException {
+ try {
+ return ctx.lookup(name);
+ } catch(NameNotFoundException e) {
+ logger.error("Could not find name ["+name+"].");
+ throw e;
+ }
+ }
+
+ static void usage(String msg) {
+ System.err.println(msg);
+ System.err.println("Usage: java " + JMSSink.class.getName()
+ + " TopicConnectionFactoryBindingName TopicBindingName username password configFile");
+ System.exit(1);
+ }
+}
diff --git a/src/java/org/apache/log4j/net/SMTPAppender.java b/src/main/java/org/apache/log4j/net/SMTPAppender.java
similarity index 64%
rename from src/java/org/apache/log4j/net/SMTPAppender.java
rename to src/main/java/org/apache/log4j/net/SMTPAppender.java
index bca7acaa80..237facd69f 100644
--- a/src/java/org/apache/log4j/net/SMTPAppender.java
+++ b/src/main/java/org/apache/log4j/net/SMTPAppender.java
@@ -1,14 +1,25 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.net;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Level;
+import org.apache.log4j.Layout;
import org.apache.log4j.helpers.CyclicBuffer;
import org.apache.log4j.helpers.OptionConverter;
import org.apache.log4j.helpers.LogLog;
@@ -19,6 +30,8 @@
import java.util.Date;
import javax.mail.Session;
+import javax.mail.Authenticator;
+import javax.mail.PasswordAuthentication;
import javax.mail.Transport;
import javax.mail.Message;
import javax.mail.MessagingException;
@@ -44,9 +57,20 @@
@since 1.0 */
public class SMTPAppender extends AppenderSkeleton {
private String to;
+ /**
+ * Comma separated list of cc recipients.
+ */
+ private String cc;
+ /**
+ * Comma separated list of bcc recipients.
+ */
+ private String bcc;
private String from;
private String subject;
private String smtpHost;
+ private String smtpUsername;
+ private String smtpPassword;
+ private boolean smtpDebug = false;
private int bufferSize = 512;
private boolean locationInfo = false;
@@ -81,28 +105,76 @@ public class SMTPAppender extends AppenderSkeleton {
recipient, from, etc. */
public
void activateOptions() {
- Properties props = new Properties (System.getProperties());
- if (smtpHost != null)
- props.put("mail.smtp.host", smtpHost);
-
-
- Session session = Session.getInstance(props, null);
- //session.setDebug(true);
+ Session session = createSession();
msg = new MimeMessage(session);
try {
- if (from != null)
- msg.setFrom(getAddress(from));
- else
- msg.setFrom();
-
- msg.setRecipients(Message.RecipientType.TO, parseAddress(to));
- if(subject != null)
- msg.setSubject(subject);
+ addressMessage(msg);
+ if(subject != null) {
+ msg.setSubject(subject);
+ }
} catch(MessagingException e) {
LogLog.error("Could not activate SMTPAppender options.", e );
}
}
+
+ /**
+ * Address message.
+ * @param msg message, may not be null.
+ * @throws MessagingException thrown if error addressing message.
+ */
+ protected void addressMessage(final Message msg) throws MessagingException {
+ if (from != null) {
+ msg.setFrom(getAddress(from));
+ } else {
+ msg.setFrom();
+ }
+
+ if (to != null && to.length() > 0) {
+ msg.setRecipients(Message.RecipientType.TO, parseAddress(to));
+ }
+
+ //Add CC receipients if defined.
+ if (cc != null && cc.length() > 0) {
+ msg.setRecipients(Message.RecipientType.CC, parseAddress(cc));
+ }
+
+ //Add BCC receipients if defined.
+ if (bcc != null && bcc.length() > 0) {
+ msg.setRecipients(Message.RecipientType.BCC, parseAddress(bcc));
+ }
+ }
+
+ /**
+ * Create mail session.
+ * @return mail session, may not be null.
+ */
+ protected Session createSession() {
+ Properties props = null;
+ try {
+ props = new Properties (System.getProperties());
+ } catch(SecurityException ex) {
+ props = new Properties();
+ }
+ if (smtpHost != null) {
+ props.put("mail.smtp.host", smtpHost);
+ }
+
+ Authenticator auth = null;
+ if(smtpPassword != null && smtpUsername != null) {
+ props.put("mail.smtp.auth", "true");
+ auth = new Authenticator() {
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(smtpUsername, smtpPassword);
+ }
+ };
+ }
+ Session session = Session.getInstance(props, auth);
+ if (smtpDebug) {
+ session.setDebug(smtpDebug);
+ }
+ return session;
+ }
/**
Perform SMTPAppender specific appending actions, mainly adding
@@ -117,6 +189,7 @@ void append(LoggingEvent event) {
event.getThreadName();
event.getNDC();
+ event.getMDCCopy();
if(locationInfo) {
event.getLocationInformation();
}
@@ -222,6 +295,7 @@ void sendBuffer() {
if (s != null) {
for(int j = 0; j < s.length; j++) {
sbuf.append(s[j]);
+ sbuf.append(Layout.LINE_SEP);
}
}
}
@@ -375,6 +449,90 @@ void setLocationInfo(boolean locationInfo) {
boolean getLocationInfo() {
return locationInfo;
}
+
+ /**
+ Set the cc recipient addresses.
+ @param addresses recipient addresses as comma separated string, may be null.
+ */
+ public void setCc(final String addresses) {
+ this.cc = addresses;
+ }
+
+ /**
+ Get the cc recipient addresses.
+ @return recipient addresses as comma separated string, may be null.
+ */
+ public String getCc() {
+ return cc;
+ }
+
+ /**
+ Set the bcc recipient addresses.
+ @param addresses recipient addresses as comma separated string, may be null.
+ */
+ public void setBcc(final String addresses) {
+ this.bcc = addresses;
+ }
+
+ /**
+ Get the bcc recipient addresses.
+ @return recipient addresses as comma separated string, may be null.
+ */
+ public String getBcc() {
+ return bcc;
+ }
+
+ /**
+ * The SmtpPassword option takes a string value which should be the password required to authenticate against
+ * the mail server.
+ * @param password password, may be null.
+ */
+ public void setSMTPPassword(final String password) {
+ this.smtpPassword = password;
+ }
+
+ /**
+ * The SmtpUsername option takes a string value which should be the username required to authenticate against
+ * the mail server.
+ * @param username user name, may be null.
+ */
+ public void setSMTPUsername(final String username) {
+ this.smtpUsername = username;
+ }
+
+ /**
+ * Setting the SmtpDebug option to true will cause the mail session to log its server interaction to stdout.
+ * This can be useful when debuging the appender but should not be used during production because username and
+ * password information is included in the output.
+ * @param debug debug flag.
+ */
+ public void setSMTPDebug(final boolean debug) {
+ this.smtpDebug = debug;
+ }
+
+ /**
+ * Get SMTP password.
+ * @return SMTP password, may be null.
+ */
+ public String getSMTPPassword() {
+ return smtpPassword;
+ }
+
+ /**
+ * Get SMTP user name.
+ * @return SMTP user name, may be null.
+ */
+ public String getSMTPUsername() {
+ return smtpUsername;
+ }
+
+ /**
+ * Get SMTP debug.
+ * @return SMTP debug flag.
+ */
+ public boolean getSMTPDebug() {
+ return smtpDebug;
+ }
}
class DefaultEvaluator implements TriggeringEventEvaluator {
@@ -386,6 +544,6 @@ class DefaultEvaluator implements TriggeringEventEvaluator {
This will mark the appender as closed and
- call then {@link #cleanUp} method.
- */
- synchronized
- public
- void close() {
+ * Close this appender.
+ *
+ * This will mark the appender as closed and call then {@link
+ * #cleanUp} method.
+ * */
+ synchronized public void close() {
if(closed)
return;
@@ -171,16 +177,14 @@ void close() {
}
/**
- Drop the connection to the remote host and release the underlying
- connector thread if it has been created
- */
- public
- void cleanUp() {
+ * Drop the connection to the remote host and release the underlying
+ * connector thread if it has been created
+ * */
+ public void cleanUp() {
if(oos != null) {
try {
oos.close();
- }
- catch(IOException e) {
+ } catch(IOException e) {
LogLog.error("Could not close oos.", e);
}
oos = null;
@@ -199,17 +203,23 @@ void connect(InetAddress address, int port) {
// First, close the previous connection if any.
cleanUp();
oos = new ObjectOutputStream(new Socket(address, port).getOutputStream());
- }
- catch(IOException e) {
- LogLog.error("Could not connect to remote log4j server at ["
- +address.getHostName()+"]. We will try again later.", e);
- fireConnector();
+ } catch(IOException e) {
+
+ String msg = "Could not connect to remote log4j server at ["
+ +address.getHostName()+"].";
+ if(reconnectionDelay > 0) {
+ msg += " We will try again later.";
+ fireConnector(); // fire the connector thread
+ } else {
+ msg += " We are not retrying.";
+ errorHandler.error(msg, e, ErrorCode.GENERIC_FAILURE);
+ }
+ LogLog.error(msg);
}
}
- public
- void append(LoggingEvent event) {
+ public void append(LoggingEvent event) {
if(event == null)
return;
@@ -234,12 +244,14 @@ void append(LoggingEvent event) {
//System.err.println("Doing oos.reset()");
oos.reset();
}
- }
- catch(IOException e) {
+ } catch(IOException e) {
oos = null;
LogLog.warn("Detected problem with connection: "+e);
if(reconnectionDelay > 0) {
fireConnector();
+ } else {
+ errorHandler.error("Detected problem with connection, not reconnecting.", e,
+ ErrorCode.GENERIC_FAILURE);
}
}
}
@@ -259,28 +271,26 @@ void fireConnector() {
InetAddress getAddressByName(String host) {
try {
return InetAddress.getByName(host);
- }
- catch(Exception e) {
+ } catch(Exception e) {
LogLog.error("Could not find address of ["+host+"].", e);
return null;
}
}
/**
- The SocketAppender does not use a layout. Hence, this method returns
- Setting this option to zero turns off reconnection
capability.
*/
- public
- void setReconnectionDelay(int delay) {
+ public void setReconnectionDelay(int delay) {
this.reconnectionDelay = delay;
}
/**
Returns value of the ReconnectionDelay option.
*/
- public
- int getReconnectionDelay() {
+ public int getReconnectionDelay() {
return reconnectionDelay;
}
@@ -377,18 +380,16 @@ void run() {
synchronized(this) {
oos = new ObjectOutputStream(socket.getOutputStream());
connector = null;
+ LogLog.debug("Connection established. Exiting connector thread.");
break;
}
- }
- catch(InterruptedException e) {
+ } catch(InterruptedException e) {
LogLog.debug("Connector interrupted. Leaving loop.");
return;
- }
- catch(java.net.ConnectException e) {
+ } catch(java.net.ConnectException e) {
LogLog.debug("Remote host "+address.getHostName()
+" refused connection.");
- }
- catch(IOException e) {
+ } catch(IOException e) {
LogLog.debug("Could not connect to " + address.getHostName()+
". Exception is " + e);
}
diff --git a/src/java/org/apache/log4j/net/SocketHubAppender.java b/src/main/java/org/apache/log4j/net/SocketHubAppender.java
similarity index 93%
rename from src/java/org/apache/log4j/net/SocketHubAppender.java
rename to src/main/java/org/apache/log4j/net/SocketHubAppender.java
index bce55792c8..836e3ffb59 100644
--- a/src/java/org/apache/log4j/net/SocketHubAppender.java
+++ b/src/main/java/org/apache/log4j/net/SocketHubAppender.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.net;
diff --git a/src/main/java/org/apache/log4j/net/SocketNode.java b/src/main/java/org/apache/log4j/net/SocketNode.java
new file mode 100644
index 0000000000..59edb38a1b
--- /dev/null
+++ b/src/main/java/org/apache/log4j/net/SocketNode.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.net;
+
+import java.net.Socket;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.BufferedInputStream;
+
+
+import org.apache.log4j.*;
+import org.apache.log4j.spi.*;
+
+// Contributors: Moses Hohman For example, the socket node might decide to log events to a
+ local file and also resent them to a second socket node.
+
+ @author Ceki Gülcü
+
+ @since 0.8.4
+*/
+public class SocketNode implements Runnable {
+
+ Socket socket;
+ LoggerRepository hierarchy;
+ ObjectInputStream ois;
+
+ static Logger logger = Logger.getLogger(SocketNode.class);
+
+ public SocketNode(Socket socket, LoggerRepository hierarchy) {
+ this.socket = socket;
+ this.hierarchy = hierarchy;
+ try {
+ ois = new ObjectInputStream(
+ new BufferedInputStream(socket.getInputStream()));
+ }
+ catch(Exception e) {
+ logger.error("Could not open ObjectInputStream to "+socket, e);
+ }
+ }
+
+ //public
+ //void finalize() {
+ //System.err.println("-------------------------Finalize called");
+ // System.err.flush();
+ //}
+
+ public void run() {
+ LoggingEvent event;
+ Logger remoteLogger;
+
+ try {
+ if (ois != null) {
+ while(true) {
+ // read an event from the wire
+ event = (LoggingEvent) ois.readObject();
+ // get a logger from the hierarchy. The name of the logger is taken to be the name contained in the event.
+ remoteLogger = hierarchy.getLogger(event.getLoggerName());
+ //event.logger = remoteLogger;
+ // apply the logger-level filter
+ if(event.getLevel().isGreaterOrEqual(remoteLogger.getEffectiveLevel())) {
+ // finally log the event as if was generated locally
+ remoteLogger.callAppenders(event);
+ }
+ }
+ }
+ } catch(java.io.EOFException e) {
+ logger.info("Caught java.io.EOFException closing conneciton.");
+ } catch(java.net.SocketException e) {
+ logger.info("Caught java.net.SocketException closing conneciton.");
+ } catch(IOException e) {
+ logger.info("Caught java.io.IOException: "+e);
+ logger.info("Closing connection.");
+ } catch(Exception e) {
+ logger.error("Unexpected exception. Closing conneciton.", e);
+ } finally {
+ if (ois != null) {
+ try {
+ ois.close();
+ } catch(Exception e) {
+ logger.info("Could not close connection.", e);
+ }
+ }
+ if (socket != null) {
+ try {
+ socket.close();
+ } catch(IOException ex) {
+ }
+ }
+ }
+ }
+}
diff --git a/src/java/org/apache/log4j/net/SocketServer.java b/src/main/java/org/apache/log4j/net/SocketServer.java
similarity index 85%
rename from src/java/org/apache/log4j/net/SocketServer.java
rename to src/main/java/org/apache/log4j/net/SocketServer.java
index 41272588df..b30c9db0db 100644
--- a/src/java/org/apache/log4j/net/SocketServer.java
+++ b/src/main/java/org/apache/log4j/net/SocketServer.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.net;
@@ -75,7 +85,7 @@ public class SocketServer {
static String GENERIC = "generic";
static String CONFIG_FILE_EXT = ".lcf";
- static Category cat = Category.getInstance(SocketServer.class);
+ static Logger cat = Logger.getLogger(SocketServer.class);
static SocketServer server;
static int port;
@@ -167,7 +177,7 @@ LoggerRepository configureHierarchy(InetAddress inetAddress) {
File configFile = new File(dir, key+CONFIG_FILE_EXT);
if(configFile.exists()) {
- Hierarchy h = new Hierarchy(new RootCategory((Level) Priority.DEBUG));
+ Hierarchy h = new Hierarchy(new RootLogger(Level.DEBUG));
hierarchyMap.put(inetAddress, h);
new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h);
@@ -184,7 +194,7 @@ LoggerRepository genericHierarchy() {
if(genericHierarchy == null) {
File f = new File(dir, GENERIC+CONFIG_FILE_EXT);
if(f.exists()) {
- genericHierarchy = new Hierarchy(new RootCategory((Level) Priority.DEBUG));
+ genericHierarchy = new Hierarchy(new RootLogger(Level.DEBUG));
new PropertyConfigurator().doConfigure(f.getAbsolutePath(), genericHierarchy);
} else {
cat.warn("Could not find config file ["+f+
diff --git a/src/java/org/apache/log4j/net/SyslogAppender.java b/src/main/java/org/apache/log4j/net/SyslogAppender.java
similarity index 58%
rename from src/java/org/apache/log4j/net/SyslogAppender.java
rename to src/main/java/org/apache/log4j/net/SyslogAppender.java
index d3c2d83396..fb9ae75939 100644
--- a/src/java/org/apache/log4j/net/SyslogAppender.java
+++ b/src/main/java/org/apache/log4j/net/SyslogAppender.java
@@ -1,17 +1,33 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.net;
import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.Layout;
-import org.apache.log4j.helpers.SyslogWriter;
import org.apache.log4j.helpers.SyslogQuietWriter;
+import org.apache.log4j.helpers.SyslogWriter;
+import org.apache.log4j.spi.LoggingEvent;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
// Contributors: Yves Bossel See It is set by the LoggingEvent constructor or set by a remote
- entity after deserialization. */
- transient public Category logger;
-
- /** The category (logger) name. */
- public final String categoryName;
-
- /** Level of logging event. Level cannot be serializable
- because it is a flyweight. Due to its special seralization it
- cannot be declared final either. */
+ /**
+ * The category of the logging event. This field is not serialized
+ * for performance reasons.
+ *
+ * It is set by the LoggingEvent constructor or set by a remote
+ * entity after deserialization.
+ *
+ * @deprecated This field will be marked as private or be completely
+ * removed in future releases. Please do not use it.
+ * */
+ transient private Category logger;
+
+ /**
+ * The category (logger) name.
+ *
+ * @deprecated This field will be marked as private in future
+ * releases. Please do not access it directly. Use the {@link
+ * #getLoggerName} method instead.
+
+ * */
+ final public String categoryName;
+
+ /**
+ * Level of logging event. Level cannot be serializable because it
+ * is a flyweight. Due to its special seralization it cannot be
+ * declared final either.
+ *
+ * This field should not be accessed directly. You shoud use the
+ * {@link #getLevel} method instead.
+ *
+ * @deprecated This field will be marked as private in future
+ * releases. Please do not access it directly. Use the {@link
+ * #getLevel} method instead.
+ * */
transient public Priority level;
/** The nested diagnostic context (NDC) of logging event. */
@@ -62,18 +97,16 @@ public class LoggingEvent implements java.io.Serializable {
/** Have we tried to do an NDC lookup? If we did, there is no need
- to do it again. Note that its value is always false when
- serialized. Thus, a receiving SocketNode will never use it's own
- (incorrect) NDC. See also writeObject method. */
+ * to do it again. Note that its value is always false when
+ * serialized. Thus, a receiving SocketNode will never use it's own
+ * (incorrect) NDC. See also writeObject method. */
private boolean ndcLookupRequired = true;
- /** Have we tried to do an MDC lookup? If we did, there is no need to
- do it again. Note that its value is always false when
- serialized. Thus, a receiving SocketNode will never use it's own
- (incorrect) MDC. See also writeObject method. */
- private boolean mdcLookupRequired = true;
-
+ /** Have we tried to do an MDC lookup? If we did, there is no need
+ * to do it again. Note that its value is always false when
+ * serialized. See also the getMDC and getMDCCopy methods. */
+ private boolean mdcCopyLookupRequired = true;
/** The application supplied message of logging event. */
transient private Object message;
@@ -111,16 +144,16 @@ public class LoggingEvent implements java.io.Serializable {
Except {@link #timeStamp} all the other fields of
- @param category The category of this event.
+ @param logger The logger generating this event.
@param level The level of this event.
@param message The message of this event.
@param throwable The throwable of this event. */
public LoggingEvent(String fqnOfCategoryClass, Category logger,
- Priority priority, Object message, Throwable throwable) {
+ Priority level, Object message, Throwable throwable) {
this.fqnOfCategoryClass = fqnOfCategoryClass;
this.logger = logger;
this.categoryName = logger.getName();
- this.level = priority;
+ this.level = level;
this.message = message;
if(throwable != null) {
this.throwableInfo = new ThrowableInformation(throwable);
@@ -134,18 +167,18 @@ public LoggingEvent(String fqnOfCategoryClass, Category logger,
Except {@link #timeStamp} all the other fields of
- @param category The category of this event.
+ @param logger The logger generating this event.
@param timeStamp the timestamp of this logging event
@param level The level of this event.
@param message The message of this event.
@param throwable The throwable of this event. */
public LoggingEvent(String fqnOfCategoryClass, Category logger,
- long timeStamp, Priority priority, Object message,
+ long timeStamp, Priority level, Object message,
Throwable throwable) {
this.fqnOfCategoryClass = fqnOfCategoryClass;
this.logger = logger;
this.categoryName = logger.getName();
- this.level = priority;
+ this.level = level;
this.message = message;
if(throwable != null) {
this.throwableInfo = new ThrowableInformation(throwable);
@@ -154,20 +187,91 @@ public LoggingEvent(String fqnOfCategoryClass, Category logger,
this.timeStamp = timeStamp;
}
+ /**
+ Create new instance.
+ @since 1.2.15
+ @param fqnOfCategoryClass Fully qualified class name
+ of Logger implementation.
+ @param logger The logger generating this event.
+ @param timeStamp the timestamp of this logging event
+ @param level The level of this event.
+ @param message The message of this event.
+ @param threadName thread name
+ @param throwable The throwable of this event.
+ @param ndc Nested diagnostic context
+ @param info Location info
+ @param properties MDC properties
+ */
+ public LoggingEvent(final String fqnOfCategoryClass,
+ final Category logger,
+ final long timeStamp,
+ final Level level,
+ final Object message,
+ final String threadName,
+ final ThrowableInformation throwable,
+ final String ndc,
+ final LocationInfo info,
+ final java.util.Map properties) {
+ super();
+ this.fqnOfCategoryClass = fqnOfCategoryClass;
+ this.logger = logger;
+ if (logger != null) {
+ categoryName = logger.getName();
+ } else {
+ categoryName = null;
+ }
+ this.level = level;
+ this.message = message;
+ if(throwable != null) {
+ this.throwableInfo = throwable;
+ }
+
+ this.timeStamp = timeStamp;
+ this.threadName = threadName;
+ ndcLookupRequired = false;
+ this.ndc = ndc;
+ this.locationInfo = info;
+ mdcCopyLookupRequired = false;
+ if (properties != null) {
+ mdcCopy = new java.util.Hashtable(properties);
+ }
+ }
/**
Set the location information for this logging event. The collected
information is cached for future use.
*/
- public
- LocationInfo getLocationInformation() {
+ public LocationInfo getLocationInformation() {
if(locationInfo == null) {
locationInfo = new LocationInfo(new Throwable(), fqnOfCategoryClass);
}
return locationInfo;
}
+ /**
+ * Return the level of this event. Use this form instead of directly
+ * accessing the Note that both the local MDC copy and the current
thread's MDC are searched.
@@ -223,11 +334,12 @@ Object getMDC(String key) {
/**
Obtain a copy of this thread's MDC prior to serialization or
- asynchronous logging. */
+ asynchronous logging.
+ */
public
void getMDCCopy() {
- if(mdcLookupRequired) {
- ndcLookupRequired = false;
+ if(mdcCopyLookupRequired) {
+ mdcCopyLookupRequired = false;
// the clone call is required for asynchronous logging.
// See also bug #5932.
Hashtable t = (Hashtable) MDC.getContext();
@@ -243,7 +355,7 @@ String getRenderedMessage() {
if(message instanceof String)
renderedMessage = (String) message;
else {
- LoggerRepository repository = logger.getHierarchy();
+ LoggerRepository repository = logger.getLoggerRepository();
if(repository instanceof RendererSupport) {
RendererSupport rs = (RendererSupport) repository;
@@ -259,9 +371,7 @@ String getRenderedMessage() {
/**
Returns the time when the application started, in milliseconds
elapsed since 01.01.1970. */
- public
- static
- long getStartTime() {
+ public static long getStartTime() {
return startTime;
}
@@ -310,7 +420,7 @@ void readLevel(ObjectInputStream ois)
} else {
Method m = (Method) methodCache.get(className);
if(m == null) {
- Class clazz = Class.forName(className);
+ Class clazz = Loader.loadClass(className);
// Note that we use Class.getDeclaredMethod instead of
// Class.getMethod. This assumes that the Level subclass
// implements the toLevel(int) method which is a
@@ -381,4 +491,114 @@ void writeLevel(ObjectOutputStream oos) throws java.io.IOException {
}
}
+ /**
+ * Set value for MDC property.
+ * This adds the specified MDC property to the event.
+ * Access to the MDC is not synchronized, so this
+ * method should only be called when it is known that
+ * no other threads are accessing the MDC.
+ * @since 1.2.15
+ * @param propName
+ * @param propValue
+ */
+ public final void setProperty(final String propName,
+ final String propValue) {
+ if (mdcCopy == null) {
+ getMDCCopy();
+ }
+ if (mdcCopy == null) {
+ mdcCopy = new Hashtable();
+ }
+ mdcCopy.put(propName, propValue);
+ }
+
+ /**
+ * Return a property for this event. The return value can be null.
+ *
+ * Equivalent to getMDC(String) in log4j 1.2. Provided
+ * for compatibility with log4j 1.3.
+ *
+ * @param key property name
+ * @return property value or null if property not set
+ * @since 1.2.15
+ */
+ public final String getProperty(final String key) {
+ Object value = getMDC(key);
+ String retval = null;
+ if (value != null) {
+ retval = value.toString();
+ }
+ return retval;
+ }
+
+ /**
+ * Check for the existence of location information without creating it
+ * (a byproduct of calling getLocationInformation).
+ * @return true if location information has been extracted.
+ * @since 1.2.15
+ */
+ public final boolean locationInformationExists() {
+ return (locationInfo != null);
+ }
+
+ /**
+ * Getter for the event's time stamp. The time stamp is calculated starting
+ * from 1970-01-01 GMT.
+ * @return timestamp
+ *
+ * @since 1.2.15
+ */
+ public final long getTimeStamp() {
+ return timeStamp;
+ }
+
+ /**
+ * Returns the set of the key values in the properties
+ * for the event.
+ *
+ * The returned set is unmodifiable by the caller.
+ *
+ * Provided for compatibility with log4j 1.3
+ *
+ * @return Set an unmodifiable set of the property keys.
+ * @since 1.2.15
+ */
+ public Set getPropertyKeySet() {
+ return getProperties().keySet();
+ }
+
+ /**
+ * Returns the set of properties
+ * for the event.
+ *
+ * The returned set is unmodifiable by the caller.
+ *
+ * Provided for compatibility with log4j 1.3
+ *
+ * @return Set an unmodifiable map of the properties.
+ * @since 1.2.15
+ */
+ public Map getProperties() {
+ getMDCCopy();
+ Map properties;
+ if (mdcCopy == null) {
+ properties = new HashMap();
+ } else {
+ properties = mdcCopy;
+ }
+ return Collections.unmodifiableMap(properties);
+ }
+
+ /**
+ * Get the fully qualified name of the calling logger sub-class/wrapper.
+ * Provided for compatibility with log4j 1.3
+ * @return fully qualified class name, may be null.
+ * @since 1.2.15
+ */
+ public String getFQNOfLoggerClass() {
+ return fqnOfCategoryClass;
+ }
+
+
+
}
diff --git a/src/main/java/org/apache/log4j/spi/NullWriter.java b/src/main/java/org/apache/log4j/spi/NullWriter.java
new file mode 100644
index 0000000000..a578910893
--- /dev/null
+++ b/src/main/java/org/apache/log4j/spi/NullWriter.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.spi;
+import java.io.Writer;
+
+/**
+ * NullWriter is an obsolete class provided only for
+ * binary compatibility with earlier versions of log4j and should not be used.
+ *
+ * @deprecated
+ */
+class NullWriter extends Writer {
+
+ public void close() {
+ // blank
+ }
+
+ public void flush() {
+ // blank
+ }
+
+ public void write(char[] cbuf, int off, int len) {
+ // blank
+ }
+}
diff --git a/src/java/org/apache/log4j/spi/OptionHandler.java b/src/main/java/org/apache/log4j/spi/OptionHandler.java
similarity index 62%
rename from src/java/org/apache/log4j/spi/OptionHandler.java
rename to src/main/java/org/apache/log4j/spi/OptionHandler.java
index 9f952323eb..2c90226825 100644
--- a/src/java/org/apache/log4j/spi/OptionHandler.java
+++ b/src/main/java/org/apache/log4j/spi/OptionHandler.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.spi;
diff --git a/src/main/java/org/apache/log4j/spi/RendererSupport.java b/src/main/java/org/apache/log4j/spi/RendererSupport.java
new file mode 100644
index 0000000000..9d69faa731
--- /dev/null
+++ b/src/main/java/org/apache/log4j/spi/RendererSupport.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.log4j.spi;
+
+import org.apache.log4j.or.ObjectRenderer;
+import org.apache.log4j.or.RendererMap;
+
+
+public interface RendererSupport {
+
+ public
+ RendererMap getRendererMap();
+
+ public
+ void setRenderer(Class renderedClass, ObjectRenderer renderer);
+
+}
diff --git a/src/java/org/apache/log4j/spi/RepositorySelector.java b/src/main/java/org/apache/log4j/spi/RepositorySelector.java
similarity index 50%
rename from src/java/org/apache/log4j/spi/RepositorySelector.java
rename to src/main/java/org/apache/log4j/spi/RepositorySelector.java
index 2d0818a0c0..9a70d6203c 100644
--- a/src/java/org/apache/log4j/spi/RepositorySelector.java
+++ b/src/main/java/org/apache/log4j/spi/RepositorySelector.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
diff --git a/src/java/org/apache/log4j/spi/RootCategory.java b/src/main/java/org/apache/log4j/spi/RootCategory.java
similarity index 54%
rename from src/java/org/apache/log4j/spi/RootCategory.java
rename to src/main/java/org/apache/log4j/spi/RootCategory.java
index 7ec80b4170..1682751811 100644
--- a/src/java/org/apache/log4j/spi/RootCategory.java
+++ b/src/main/java/org/apache/log4j/spi/RootCategory.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.spi;
@@ -13,16 +23,7 @@
// Contibutors: Mathias Bogaert
/**
- RootCategory sits at the top of the category hierachy. It is a
- regular category except that it provides several guarantees.
-
- First, it cannot be assigned a First, it cannot be assigned a For example the {@link org.apache.log4j.net.SMTPAppender} sends
+ an email when the {@link #isTriggeringEvent} method returns
+ The error message is printed on The error message is printed on The filter admits three options LevelMin, LevelMax
+ and AcceptOnMatch.
+
+ If the level of the {@link LoggingEvent} is not between Min and Max
+ (inclusive), then {@link Filter#DENY} is returned.
+
+ If the Logging event level is within the specified range, then if
+ AcceptOnMatch is true, {@link Filter#ACCEPT} is returned, and if
+ AcceptOnMatch is false, {@link Filter#NEUTRAL} is returned.
+
+ If Refer to the {@link
+ org.apache.log4j.AppenderSkeleton#setThreshold setThreshold} method
+ available to The filter admits two options StringToMatch and
- AcceptOnMatch. If there is a match between the value of the
- StringToMatch option and the message of the {@link LoggingEvent},
- then the {@link #decide} method returns {@link Filter#ACCEPT} if
- the AcceptOnMatch option value is true, if it is false then
- {@link Filter#DENY} is returned. If there is no match, {@link
- Filter#NEUTRAL} is returned.
-
- See configuration files test6.xml, test7.xml, test8.xml, test9.xml, and test10.xml for examples of
- seeting up a The filter admits two options StringToMatch and
+ * AcceptOnMatch. If there is a match between the value of the
+ * StringToMatch option and the message of the {@link org.apache.log4j.spi.LoggingEvent},
+ * then the {@link #decide(LoggingEvent)} method returns {@link org.apache.log4j.spi.Filter#ACCEPT} if
+ * the AcceptOnMatch option value is true, if it is false then
+ * {@link org.apache.log4j.spi.Filter#DENY} is returned. If there is no match, {@link
+ * org.apache.log4j.spi.Filter#NEUTRAL} is returned.
+ *
+ * @author Ceki Gülcü
+ * @since 0.9.0
+ */
public class StringMatchFilter extends Filter {
/**
diff --git a/src/java/org/apache/log4j/varia/package.html b/src/main/java/org/apache/log4j/varia/package.html
similarity index 100%
rename from src/java/org/apache/log4j/varia/package.html
rename to src/main/java/org/apache/log4j/varia/package.html
diff --git a/src/java/org/apache/log4j/xml/DOMConfigurator.java b/src/main/java/org/apache/log4j/xml/DOMConfigurator.java
similarity index 65%
rename from src/java/org/apache/log4j/xml/DOMConfigurator.java
rename to src/main/java/org/apache/log4j/xml/DOMConfigurator.java
index 8060989d80..15b04661da 100644
--- a/src/java/org/apache/log4j/xml/DOMConfigurator.java
+++ b/src/main/java/org/apache/log4j/xml/DOMConfigurator.java
@@ -1,33 +1,60 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.xml;
-import java.util.*;
-
-import java.net.URL;
-
-import org.w3c.dom.*;
-import java.lang.reflect.Method;
-import org.apache.log4j.*;
-import org.apache.log4j.spi.*;
-import org.apache.log4j.or.RendererMap;
-import org.apache.log4j.helpers.*;
+import org.apache.log4j.Appender;
+import org.apache.log4j.Layout;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
import org.apache.log4j.config.PropertySetter;
-
+import org.apache.log4j.helpers.FileWatchdog;
+import org.apache.log4j.helpers.Loader;
+import org.apache.log4j.helpers.LogLog;
+import org.apache.log4j.helpers.OptionConverter;
+import org.apache.log4j.or.RendererMap;
+import org.apache.log4j.spi.AppenderAttachable;
+import org.apache.log4j.spi.Configurator;
+import org.apache.log4j.spi.ErrorHandler;
+import org.apache.log4j.spi.Filter;
+import org.apache.log4j.spi.LoggerFactory;
+import org.apache.log4j.spi.LoggerRepository;
+import org.apache.log4j.spi.OptionHandler;
+import org.apache.log4j.spi.RendererSupport;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
-import java.io.FileInputStream;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
-import java.io.IOException;
+import java.lang.reflect.Method;
import java.net.URL;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.FactoryConfigurationError;
+import java.util.Hashtable;
+import java.util.Properties;
// Contributors: Mark Womack
// Arun Katkere
@@ -36,7 +63,7 @@
Use this class to initialize the log4j environment using a DOM tree.
The DTD is specified in log4j.dtd.
+ href="log4j.dtd">log4j.dtd.
Sometimes it is useful to see how log4j is reading configuration
files. You can enable log4j internal logging by defining the
@@ -69,6 +96,7 @@ public class DOMConfigurator implements Configurator {
static final String LOGGER = "logger";
static final String LOGGER_REF = "logger-ref";
static final String CATEGORY_FACTORY_TAG = "categoryFactory";
+ static final String LOGGER_FACTORY_TAG = "loggerFactory";
static final String NAME_ATTR = "name";
static final String CLASS_ATTR = "class";
static final String VALUE_ATTR = "value";
@@ -98,6 +126,8 @@ public class DOMConfigurator implements Configurator {
Properties props;
LoggerRepository repository;
+ protected LoggerFactory catFactory = null;
+
/**
No argument constructor.
*/
@@ -153,6 +183,48 @@ Appender findAppenderByReference(Element appenderRef) {
return findAppenderByName(doc, appenderName);
}
+ /**
+ * Delegates unrecognized content to created instance if
+ * it supports UnrecognizedElementParser.
+ * @since 1.2.15
+ * @param instance instance, may be null.
+ * @param element element, may not be null.
+ * @param props properties
+ * @throws IOException thrown if configuration of owner object
+ * should be abandoned.
+ */
+ private static void parseUnrecognizedElement(final Object instance,
+ final Element element,
+ final Properties props) throws Exception {
+ boolean recognized = false;
+ if (instance instanceof UnrecognizedElementHandler) {
+ recognized = ((UnrecognizedElementHandler) instance).parseUnrecognizedElement(
+ element, props);
+ }
+ if (!recognized) {
+ LogLog.warn("Unrecognized element " + element.getNodeName());
+ }
+ }
+
+ /**
+ * Delegates unrecognized content to created instance if
+ * it supports UnrecognizedElementParser and catches and
+ * logs any exception.
+ * @since 1.2.15
+ * @param instance instance, may be null.
+ * @param element element, may not be null.
+ * @param props properties
+ */
+ private static void quietParseUnrecognizedElement(final Object instance,
+ final Element element,
+ final Properties props) {
+ try {
+ parseUnrecognizedElement(instance, element, props);
+ } catch (Exception ex) {
+ LogLog.error("Error in extension content: ", ex);
+ }
+ }
+
/**
Used internally to parse an appender element.
*/
@@ -161,7 +233,7 @@ Appender parseAppender (Element appenderElement) {
String className = subst(appenderElement.getAttribute(CLASS_ATTR));
LogLog.debug("Class name: [" + className+']');
try {
- Object instance = Class.forName(className).newInstance();
+ Object instance = Loader.loadClass(className).newInstance();
Appender appender = (Appender)instance;
PropertySetter propSetter = new PropertySetter(appender);
@@ -204,7 +276,9 @@ else if (currentElement.getTagName().equals(APPENDER_REF_TAG)) {
refName+ "] to appender named ["+ appender.getName()+
"] which does not implement org.apache.log4j.spi.AppenderAttachable.");
}
- }
+ } else {
+ parseUnrecognizedElement(instance, currentElement, props);
+ }
}
}
propSetter.activate();
@@ -247,12 +321,15 @@ void parseErrorHandler(Element element, Appender appender) {
eh.setBackupAppender(findAppenderByReference(currentElement));
} else if(tagName.equals(LOGGER_REF)) {
String loggerName = currentElement.getAttribute(REF_ATTR);
- Logger logger = repository.getLogger(loggerName);
+ Logger logger = (catFactory == null) ? repository.getLogger(loggerName)
+ : repository.getLogger(loggerName, catFactory);
eh.setLogger(logger);
} else if(tagName.equals(ROOT_REF)) {
Logger root = repository.getRootLogger();
eh.setLogger(root);
- }
+ } else {
+ quietParseUnrecognizedElement(eh, currentElement, props);
+ }
}
}
propSetter.activate();
@@ -281,7 +358,9 @@ void parseFilters(Element element, Appender appender) {
String tagName = currentElement.getTagName();
if(tagName.equals(PARAM_TAG)) {
setParameter(currentElement, propSetter);
- }
+ } else {
+ quietParseUnrecognizedElement(filter, currentElement, props);
+ }
}
}
propSetter.activate();
@@ -306,12 +385,12 @@ void parseCategory (Element loggerElement) {
if(EMPTY_STR.equals(className)) {
LogLog.debug("Retreiving an instance of org.apache.log4j.Logger.");
- cat = repository.getLogger(catName);
+ cat = (catFactory == null) ? repository.getLogger(catName) : repository.getLogger(catName, catFactory);
}
else {
LogLog.debug("Desired logger sub-class: ["+className+']');
try {
- Class clazz = Class.forName(className);
+ Class clazz = Loader.loadClass(className);
Method getInstanceMethod = clazz.getMethod("getLogger",
ONE_STRING_PARAM);
cat = (Logger) getInstanceMethod.invoke(null, new Object[] {catName});
@@ -350,10 +429,15 @@ void parseCategoryFactory(Element factoryElement) {
}
else {
LogLog.debug("Desired category factory: ["+className+']');
- Object catFactory = OptionConverter.instantiateByClassName(className,
+ Object factory = OptionConverter.instantiateByClassName(className,
LoggerFactory.class,
null);
- PropertySetter propSetter = new PropertySetter(catFactory);
+ if (factory instanceof LoggerFactory) {
+ catFactory = (LoggerFactory) factory;
+ } else {
+ LogLog.error("Category Factory class " + className + " does not implement org.apache.log4j.LoggerFactory");
+ }
+ PropertySetter propSetter = new PropertySetter(factory);
Element currentElement = null;
Node currentNode = null;
@@ -366,7 +450,9 @@ void parseCategoryFactory(Element factoryElement) {
currentElement = (Element)currentNode;
if (currentElement.getTagName().equals(PARAM_TAG)) {
setParameter(currentElement, propSetter);
- }
+ } else {
+ quietParseUnrecognizedElement(factory, currentElement, props);
+ }
}
}
}
@@ -428,7 +514,9 @@ void parseChildrenOfLoggerElement(Element catElement,
parseLevel(currentElement, cat, isRoot);
} else if(tagName.equals(PARAM_TAG)) {
setParameter(currentElement, propSetter);
- }
+ } else {
+ quietParseUnrecognizedElement(cat, currentElement, props);
+ }
}
}
propSetter.activate();
@@ -442,7 +530,7 @@ Layout parseLayout (Element layout_element) {
String className = subst(layout_element.getAttribute(CLASS_ATTR));
LogLog.debug("Parsing layout of class: \""+className+"\"");
try {
- Object instance = Class.forName(className).newInstance();
+ Object instance = Loader.loadClass(className).newInstance();
Layout layout = (Layout)instance;
PropertySetter propSetter = new PropertySetter(layout);
@@ -456,7 +544,9 @@ Layout parseLayout (Element layout_element) {
String tagName = currentElement.getTagName();
if(tagName.equals(PARAM_TAG)) {
setParameter(currentElement, propSetter);
- }
+ } else {
+ parseUnrecognizedElement(instance, currentElement, props);
+ }
}
}
@@ -493,7 +583,7 @@ void parseLevel(Element element, Logger logger, boolean isRoot) {
String priStr = subst(element.getAttribute(VALUE_ATTR));
LogLog.debug("Level value for "+catName+" is ["+priStr+"].");
- if(INHERITED.equals(priStr)) {
+ if(INHERITED.equalsIgnoreCase(priStr) || NULL.equalsIgnoreCase(priStr)) {
if(isRoot) {
LogLog.error("Root level cannot be inherited. Ignoring directive.");
} else {
@@ -506,7 +596,7 @@ void parseLevel(Element element, Logger logger, boolean isRoot) {
} else {
LogLog.debug("Desired Level sub-class: ["+className+']');
try {
- Class clazz = Class.forName(className);
+ Class clazz = Loader.loadClass(className);
Method toLevelMethod = clazz.getMethod("toLevel",
ONE_STRING_PARAM);
Level pri = (Level) toLevelMethod.invoke(null,
@@ -524,10 +614,7 @@ void parseLevel(Element element, Logger logger, boolean isRoot) {
protected
void setParameter(Element elem, PropertySetter propSetter) {
- String name = subst(elem.getAttribute(NAME_ATTR));
- String value = (elem.getAttribute(VALUE_ATTR));
- value = subst(OptionConverter.convertSpecialChars(value));
- propSetter.setProperty(name, value);
+ setParameter(elem, propSetter, props);
}
@@ -575,34 +662,37 @@ void configureAndWatch(String configFilename, long delay) {
xdog.setDelay(delay);
xdog.start();
}
+
+ private interface ParseAction {
+ Document parse(final DocumentBuilder parser) throws SAXException, IOException;
+ }
+
public
- void doConfigure(String filename, LoggerRepository repository) {
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(filename);
- doConfigure(fis, repository);
- } catch(IOException e) {
- LogLog.error("Could not open ["+filename+"].", e);
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch(java.io.IOException e) {
- LogLog.error("Could not close ["+filename+"].", e);
- }
- }
- }
+ void doConfigure(final String filename, LoggerRepository repository) {
+ ParseAction action = new ParseAction() {
+ public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
+ return parser.parse(new File(filename));
+ }
+ public String toString() {
+ return "file [" + filename + "]";
+ }
+ };
+ doConfigure(action, repository);
}
public
- void doConfigure(URL url, LoggerRepository repository) {
- try {
- doConfigure(url.openStream(), repository);
- } catch(IOException e) {
- LogLog.error("Could not open ["+url+"].", e);
- }
+ void doConfigure(final URL url, LoggerRepository repository) {
+ ParseAction action = new ParseAction() {
+ public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
+ return parser.parse(url.toString());
+ }
+ public String toString() {
+ return "url [" + url.toString() + "]";
+ }
+ };
+ doConfigure(action, repository);
}
/**
@@ -611,9 +701,19 @@ void doConfigure(URL url, LoggerRepository repository) {
*/
public
- void doConfigure(InputStream inputStream, LoggerRepository repository)
+ void doConfigure(final InputStream inputStream, LoggerRepository repository)
throws FactoryConfigurationError {
- doConfigure(new InputSource(inputStream), repository);
+ ParseAction action = new ParseAction() {
+ public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
+ InputSource inputSource = new InputSource(inputStream);
+ inputSource.setSystemId("dummy://log4j.dtd");
+ return parser.parse(inputSource);
+ }
+ public String toString() {
+ return "input stream [" + inputStream.toString() + "]";
+ }
+ };
+ doConfigure(action, repository);
}
/**
@@ -622,9 +722,19 @@ void doConfigure(InputStream inputStream, LoggerRepository repository)
*/
public
- void doConfigure(Reader reader, LoggerRepository repository)
+ void doConfigure(final Reader reader, LoggerRepository repository)
throws FactoryConfigurationError {
- doConfigure(new InputSource(reader), repository);
+ ParseAction action = new ParseAction() {
+ public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
+ InputSource inputSource = new InputSource(reader);
+ inputSource.setSystemId("dummy://log4j.dtd");
+ return parser.parse(inputSource);
+ }
+ public String toString() {
+ return "reader [" + reader.toString() + "]";
+ }
+ };
+ doConfigure(action, repository);
}
/**
@@ -633,8 +743,25 @@ void doConfigure(Reader reader, LoggerRepository repository)
*/
protected
- void doConfigure(InputSource inputSource, LoggerRepository repository)
+ void doConfigure(final InputSource inputSource, LoggerRepository repository)
throws FactoryConfigurationError {
+ if (inputSource.getSystemId() == null) {
+ inputSource.setSystemId("dummy://log4j.dtd");
+ }
+ ParseAction action = new ParseAction() {
+ public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
+ return parser.parse(inputSource);
+ }
+ public String toString() {
+ return "input source [" + inputSource.toString() + "]";
+ }
+ };
+ doConfigure(action, repository);
+ }
+
+
+ private final void doConfigure(final ParseAction action, final LoggerRepository repository)
+ throws FactoryConfigurationError {
DocumentBuilderFactory dbf = null;
this.repository = repository;
try {
@@ -651,39 +778,28 @@ void doConfigure(InputSource inputSource, LoggerRepository repository)
}
try {
- // This makes ID/IDREF attributes to have a meaning. Don't ask
- // me why.
dbf.setValidating(true);
- //dbf.setNamespaceAware(true);
DocumentBuilder docBuilder = dbf.newDocumentBuilder();
- docBuilder.setErrorHandler(new SAXErrorHandler());
- Class clazz = this.getClass();
- URL dtdURL = clazz.getResource("/org/apache/log4j/xml/log4j.dtd");
- if(dtdURL == null) {
- LogLog.error("Could not find [log4j.dtd]. Used ["+clazz.getClassLoader()+
- "] class loader in the search.");
- }
- else {
- LogLog.debug("URL to log4j.dtd is [" + dtdURL.toString()+"].");
- inputSource.setSystemId(dtdURL.toString());
- }
- Document doc = docBuilder.parse(inputSource);
+ docBuilder.setErrorHandler(new SAXErrorHandler());
+ docBuilder.setEntityResolver(new Log4jEntityResolver());
+
+ Document doc = action.parse(docBuilder);
parse(doc.getDocumentElement());
} catch (Exception e) {
// I know this is miserable...
- LogLog.error("Could not parse input source ["+inputSource+"].", e);
+ LogLog.error("Could not parse "+ action.toString() + ".", e);
}
}
- /**
- Configure by taking in an DOM element.
- */
- public void doConfigure(Element element, LoggerRepository repository) {
- this.repository = repository;
- parse(element);
- }
+ /**
+ Configure by taking in an DOM element.
+ */
+ public void doConfigure(Element element, LoggerRepository repository) {
+ this.repository = repository;
+ parse(element);
+ }
/**
@@ -733,9 +849,9 @@ void parse(Element element) {
// "debug" attribute is returned as the empty string.
if(!debugAttrib.equals("") && !debugAttrib.equals("null")) {
LogLog.setInternalDebugging(OptionConverter.toBoolean(debugAttrib, true));
- }
- else
+ } else {
LogLog.debug("Ignoring " + INTERNAL_DEBUG_ATTR + " attribute.");
+ }
String confDebug = subst(element.getAttribute(CONFIG_DEBUG_ATTR));
@@ -772,7 +888,7 @@ void parse(Element element) {
currentElement = (Element) currentNode;
tagName = currentElement.getTagName();
- if (tagName.equals(CATEGORY_FACTORY_TAG)) {
+ if (tagName.equals(CATEGORY_FACTORY_TAG) || tagName.equals(LOGGER_FACTORY_TAG)) {
parseCategoryFactory(currentElement);
}
}
@@ -790,32 +906,112 @@ void parse(Element element) {
parseRoot(currentElement);
} else if(tagName.equals(RENDERER_TAG)) {
parseRenderer(currentElement);
- }
+ } else if (!(tagName.equals(APPENDER_TAG)
+ || tagName.equals(CATEGORY_FACTORY_TAG)
+ || tagName.equals(LOGGER_FACTORY_TAG))) {
+ quietParseUnrecognizedElement(repository, currentElement, props);
+ }
}
}
}
protected
- String subst(String value) {
- try {
- return OptionConverter.substVars(value, props);
- } catch(IllegalArgumentException e) {
- LogLog.warn("Could not perform variable substitution.", e);
- return value;
- }
+ String subst(final String value) {
+ return subst(value, props);
}
+
+ /**
+ * Substitutes property value for any references in expression.
+ *
+ * @param value value from configuration file, may contain
+ * literal text, property references or both
+ * @param props properties.
+ * @return evaluated expression, may still contain expressions
+ * if unable to expand.
+ * @since 1.2.15
+ */
+ public static String subst(final String value, final Properties props) {
+ try {
+ return OptionConverter.substVars(value, props);
+ } catch (IllegalArgumentException e) {
+ LogLog.warn("Could not perform variable substitution.", e);
+ return value;
+ }
+ }
+
+
+ /**
+ * Sets a parameter based from configuration file content.
+ *
+ * @param elem param element, may not be null.
+ * @param propSetter property setter, may not be null.
+ * @param props properties
+ * @since 1.2.15
+ */
+ public static void setParameter(final Element elem,
+ final PropertySetter propSetter,
+ final Properties props) {
+ String name = subst(elem.getAttribute("name"), props);
+ String value = (elem.getAttribute("value"));
+ value = subst(OptionConverter.convertSpecialChars(value), props);
+ propSetter.setProperty(name, value);
+ }
+
+ /**
+ * Creates an object and processes any nested param elements
+ * but does not call activateOptions. If the class also supports
+ * UnrecognizedElementParser, the parseUnrecognizedElement method
+ * will be call for any child elements other than param.
+ *
+ * @param element element, may not be null.
+ * @param props properties
+ * @param expectedClass interface or class expected to be implemented
+ * by created class
+ * @return created class or null.
+ * @throws Exception thrown if the contain object should be abandoned.
+ * @since 1.2.15
+ */
+ public static Object parseElement(final Element element,
+ final Properties props,
+ final Class expectedClass) throws Exception {
+ String clazz = subst(element.getAttribute("class"), props);
+ Object instance = OptionConverter.instantiateByClassName(clazz,
+ expectedClass, null);
+
+ if (instance != null) {
+ PropertySetter propSetter = new PropertySetter(instance);
+ NodeList children = element.getChildNodes();
+ final int length = children.getLength();
+
+ for (int loop = 0; loop < length; loop++) {
+ Node currentNode = children.item(loop);
+ if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element currentElement = (Element) currentNode;
+ String tagName = currentElement.getTagName();
+ if (tagName.equals("param")) {
+ setParameter(currentElement, propSetter, props);
+ } else {
+ parseUnrecognizedElement(instance, currentElement, props);
+ }
+ }
+ }
+ return instance;
+ }
+ return null;
+ }
+
}
class XMLWatchdog extends FileWatchdog {
- XMLWatchdog(String filename) {
+ XMLWatchdog(String filename) {
super(filename);
}
/**
- Call {@link PropertyConfigurator#configure(String)} with the
+ Call {@link DOMConfigurator#configure(String)} with the
For example, if This approach enforces the independence of the XMLLayout and the
+ * appender where it is embedded.
+ *
+ * The If you are embedding this layout within an {@link
+ * org.apache.log4j.net.SMTPAppender} then make sure to set the
+ * LocationInfo option of that appender as well.
+ * */
+ public void setLocationInfo(boolean flag) {
+ locationInfo = flag;
+ }
+
+ /**
+ Returns the current value of the LocationInfo option.
+ */
+ public boolean getLocationInfo() {
+ return locationInfo;
+ }
+
+ /**
+ * Sets whether MDC key-value pairs should be output, default false.
+ * @param flag new value.
+ */
+ public void setProperties(final boolean flag) {
+ properties = flag;
+ }
+
+ /**
+ * Gets whether MDC key-value pairs should be output.
+ * @return true if MDC key-value pairs are output.
+ */
+ public boolean getProperties() {
+ return properties;
+ }
+
+ /** No options to activate. */
+ public void activateOptions() {
+ }
+
+
+ /**
+ * Formats a {@link org.apache.log4j.spi.LoggingEvent} in conformance with the log4j.dtd.
+ * */
+ public String format(final LoggingEvent event) {
+
+ // Reset working buffer. If the buffer is too large, then we need a new
+ // one in order to avoid the penalty of creating a large array.
+ if(buf.capacity() > UPPER_LIMIT) {
+ buf = new StringBuffer(DEFAULT_SIZE);
+ } else {
+ buf.setLength(0);
+ }
+
+ // We yield to the \r\n heresy.
+
+ buf.append(" Sample XML files sample1.xml
+ and sample2.xml are provided.
+
+
+ Note that the log4j.dtd is not in the local directory.
+ It is found by the class loader.
+
+ @author Ceki Gülcü
+
+*/
+public class XMLSample {
+
+ static Logger cat = Logger.getLogger(XMLSample.class);
+
+ public
+ static
+ void main(String argv[]) {
+
+ if(argv.length == 1)
+ init(argv[0]);
+ else
+ Usage("Wrong number of arguments.");
+ sample();
+ }
+
+ static
+ void Usage(String msg) {
+ System.err.println(msg);
+ System.err.println( "Usage: java " + XMLSample.class.getName() +
+ "configFile");
+ System.exit(1);
+ }
+
+ static
+ void init(String configFile) {
+ DOMConfigurator.configure(configFile);
+ }
+
+ static
+ void sample() {
+ int i = -1;
+ cat.debug("Message " + ++i);
+ cat.warn ("Message " + ++i);
+ cat.error("Message " + ++i);
+ Exception e = new Exception("Just testing");
+ cat.debug("Message " + ++i, e);
+ }
+}
diff --git a/src/java/org/apache/log4j/xml/examples/sample1.xml b/src/main/javadoc/org/apache/log4j/xml/examples/sample1.xml
similarity index 100%
rename from src/java/org/apache/log4j/xml/examples/sample1.xml
rename to src/main/javadoc/org/apache/log4j/xml/examples/sample1.xml
diff --git a/src/java/org/apache/log4j/xml/examples/sample2.xml b/src/main/javadoc/org/apache/log4j/xml/examples/sample2.xml
similarity index 100%
rename from src/java/org/apache/log4j/xml/examples/sample2.xml
rename to src/main/javadoc/org/apache/log4j/xml/examples/sample2.xml
diff --git a/src/java/org/apache/log4j/xml/examples/sample3.xml b/src/main/javadoc/org/apache/log4j/xml/examples/sample3.xml
similarity index 100%
rename from src/java/org/apache/log4j/xml/examples/sample3.xml
rename to src/main/javadoc/org/apache/log4j/xml/examples/sample3.xml
diff --git a/src/java/org/apache/log4j/xml/examples/sample4.xml b/src/main/javadoc/org/apache/log4j/xml/examples/sample4.xml
similarity index 100%
rename from src/java/org/apache/log4j/xml/examples/sample4.xml
rename to src/main/javadoc/org/apache/log4j/xml/examples/sample4.xml
diff --git a/src/java/org/apache/log4j/xml/examples/sample5.xml b/src/main/javadoc/org/apache/log4j/xml/examples/sample5.xml
similarity index 100%
rename from src/java/org/apache/log4j/xml/examples/sample5.xml
rename to src/main/javadoc/org/apache/log4j/xml/examples/sample5.xml
diff --git a/src/java/org/apache/log4j/xml/log4j.dtd b/src/main/javadoc/org/apache/log4j/xml/log4j.dtd
similarity index 66%
rename from src/java/org/apache/log4j/xml/log4j.dtd
rename to src/main/javadoc/org/apache/log4j/xml/log4j.dtd
index 12f373cdba..66f8fcb36a 100644
--- a/src/java/org/apache/log4j/xml/log4j.dtd
+++ b/src/main/javadoc/org/apache/log4j/xml/log4j.dtd
@@ -8,23 +8,25 @@
elements,appender elements, categories and an optional root
element. -->
-
+
-
-
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -40,9 +42,11 @@ element. -->
-
+
@@ -68,7 +72,7 @@ element. -->
@@ -106,7 +110,7 @@ element. -->
@@ -115,11 +119,45 @@ element. -->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -143,8 +181,8 @@ element. -->
diff --git a/src/main/resources/META-INF/LICENSE b/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000000..6279e5206d
--- /dev/null
+++ b/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 1999-2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..0375732360
--- /dev/null
+++ b/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,5 @@
+Apache log4j
+Copyright 2007 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file
diff --git a/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties b/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties
new file mode 100644
index 0000000000..10e30ba828
--- /dev/null
+++ b/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties
@@ -0,0 +1,16 @@
+# For the general syntax of property based configuration files see the
+# documenation of org.apache.log4j.PropertyConfigurator.
+
+# The root category uses the appender called A1. Since no priority is
+# specified, the root category assumes the default priority for root
+# which is DEBUG in log4j. The root category is the only category that
+# has a default priority. All other categories need not be assigned a
+# priority in which case they inherit their priority from the
+# hierarchy.
+
+log4j.rootCategory=, A1
+
+# A1 is set to be a LogMonitorAppender which outputs to a swing
+# logging console.
+
+log4j.appender.A1=org.apache.log4j.lf5.LF5Appender
diff --git a/src/java/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif b/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif
similarity index 100%
rename from src/java/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif
rename to src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif
diff --git a/src/java/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif b/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif
similarity index 100%
rename from src/java/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif
rename to src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif
diff --git a/src/java/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif b/src/main/resources/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif
similarity index 100%
rename from src/java/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif
rename to src/main/resources/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif
diff --git a/src/main/resources/org/apache/log4j/xml/log4j.dtd b/src/main/resources/org/apache/log4j/xml/log4j.dtd
new file mode 100644
index 0000000000..63d28c990f
--- /dev/null
+++ b/src/main/resources/org/apache/log4j/xml/log4j.dtd
@@ -0,0 +1,226 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/org/apache/log4j/xml/logger.dtd b/src/main/resources/org/apache/log4j/xml/logger.dtd
new file mode 100644
index 0000000000..d5f40b78e7
--- /dev/null
+++ b/src/main/resources/org/apache/log4j/xml/logger.dtd
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/ntdll/EventLogCategories.mc b/src/ntdll/EventLogCategories.mc
new file mode 100644
index 0000000000..f017900055
--- /dev/null
+++ b/src/ntdll/EventLogCategories.mc
@@ -0,0 +1,46 @@
+;
+; Licensed to the Apache Software Foundation (ASF) under one
+; or more contributor license agreements. See the NOTICE file
+; distributed with this work for additional information
+; regarding copyright ownership. The ASF licenses this file
+; to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance
+; with the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing,
+; software distributed under the License is distributed on an
+; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+; KIND, either express or implied. See the License for the
+; specific language governing permissions and limitations
+; under the License.
+;
+MessageId=1
+Language=English
+Trace
+.
+MessageId=2
+Language=English
+Debug
+.
+MessageId=3
+Language=English
+Info
+.
+MessageId=4
+Language=English
+Warn
+.
+MessageId=5
+Language=English
+Error
+.
+MessageId=6
+Language=English
+Fatal
+.
+MessageId=0x1000
+Language=English
+%1
+.
diff --git a/src/ntdll/MSG00001.bin b/src/ntdll/MSG00001.bin
new file mode 100644
index 0000000000..b6a1996851
Binary files /dev/null and b/src/ntdll/MSG00001.bin differ
diff --git a/src/ntdll/NTEventLogAppender.rc b/src/ntdll/NTEventLogAppender.rc
new file mode 100755
index 0000000000..f5e2eb1e5f
--- /dev/null
+++ b/src/ntdll/NTEventLogAppender.rc
@@ -0,0 +1,125 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+//
+// Message file include
+//
+LANGUAGE 0x9,0x1
+1 11 MSG00001.bin
+// Microsoft Visual C++ generated resource script.
+//
+#include "windows.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+//#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1, 2, 15, 1
+ PRODUCTVERSION 1, 2, 15, 1
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "Apache Software Foundation"
+ VALUE "FileDescription", "Platform methods for NTEventLogAppender"
+ VALUE "FileVersion", "1, 2, 15, 1"
+ VALUE "InternalName", "NTEventLogAppender"
+ VALUE "LegalCopyright", "Licensed to the Apache Software Foundation (ASF) under one or more\ncontributor license agreements. See the NOTICE file distributed with\nthis work for additional information regarding copyright ownership.\nThe ASF licenses this file to You under the Apache License, Version 2.0\n(the ""License""); you may not use this file except in compliance with\nthe License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an ""AS IS"" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."
+ VALUE "OriginalFilename", "NTEventLogAppender.dll"
+ VALUE "ProductName", "Apache log4j"
+ VALUE "ProductVersion", "1, 2, 15, 1"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/src/ntdll/build.xml b/src/ntdll/build.xml
new file mode 100755
index 0000000000..3a26b86c20
--- /dev/null
+++ b/src/ntdll/build.xml
@@ -0,0 +1,99 @@
+
+
+
+ Extends {@link Writer} with methods that return immediately
+ * without doing anything. This class is used to measure the cost of
+ * constructing a log message but not actually writing to any device.
+ * The
+ * The
+ * Package to measure the performance of the different log4j
+ components.
+ The
+ log4j is a tool to help the programmer output log statements to a
+ variety of output targets.
+ In case of problems with an application, it is helpful to
+ enable logging so that the problem can be located. With log4j
+ it is possible to enable logging at runtime without modifying
+ the application binary. The log4j package is designed so that
+ log statements can remain in shipped code without
+ incurring a high performance cost. It follows that the speed
+ of logging (or rather not logging) is capital.
+ At the same time, log output can be so voluminous that it quickly
+ becomes overwhelming. One of the distinctive features of log4j is the
+ notion of hierarchical loggers. Using loggers it is
+ possible to selectively control which log statements are output at
+ arbitrary granularity.
+ log4j is designed with two three goals in mind:
+ reliability, speed and flexibility. There is a tight balance
+ between these requirements. We believe that log4j strikes the
+ right balance.
+ No. log4j is not reliable. It is a best-effort
+ fail-stop logging system.
+ By fail-stop, we mean that log4j will not throw unexpected
+ exceptions at run-time potentially causing your application to
+ crash. If for any reason, log4j throws an uncaught exception,
+ please send an email to the log4j-user@logging.apache.org
+ mailing list. Uncaught exceptions are handled as serious bugs
+ requiring immediate attention.
+ Moreover, log4j will not revert to System.out or System.err
+ when its designated output stream is not opened, is not writable or
+ becomes full. This avoids corrupting an otherwise working program by
+ flooding the user's terminal because logging fails. However, log4j
+ will output a single message to System.err indicating that logging can
+ not be performed.
+ Log4j versions upto and including 1.2.8 are
+ compatible with JDK 1.1.x and later. Log4j version 1.3 will
+ be compatilble with JDK 1.2 and later.
+ The DOMConfigurator is based on the DOM Level 1
+ API. The DOMConfigurator.configure(Element) method will work
+ with any XML parser that will pass it a DOM tree.
+ The DOMConfigurator.configure(String filename) method and its
+ variants require a JAXP compatible XML parser, for example Xerces or Sun's
+ parser. Compiling the DOMConfigurator requires the presence of a
+ JAXP parser in the classpath.
+ The The log4j test code relies on the JUnit testing framework.
+ log4j is optimized for speed. log4j is based on a named logger hierarchy. log4j is fail-stop. However, altough it certainly
+ strives to ensure delivery, log4j does not guarantee that
+ each log statement will be delivered to its destination.
+ log4j is thread-safe. log4j is not restricted to a predefined set of
+ facilities. Logging behavior can be set at runtime using a
+ configuration file. Configuration files can be property
+ files or in XML format. log4j is designed to handle Java Exceptions from the
+ start. log4j can direct its output to a file, the console,
+ an log4j uses 5 levels, namely DEBUG, INFO, WARN, ERROR and
+ FATAL.
+ The format of the log output can be easily changed by
+ extending the The target of the log output as well as the writing
+ strategy can be altered by implementations of the
+ log4j supports multiple output appenders per logger.
+ log4j supports internationalization. See the Make sure to read the short
+ manual. It is also recommended to you read The complete
+ log4j manual which is much more detailed and up to
+ date. Both documents were written by Ceki Gülcü.
+ Yes, log4j is thread-safe. Log4j components are designed to
+ be used in heavily multithreaded systems. The log output can be customized in many ways. Moreover,
+ one can completely override the output format by implementing
+ one's own Layout.
+ Here is an example output using PatternLayout with
+ the conversion pattern "%r [%t] %-5p %c{2} %x - %m%n"
+ The first field is the number of milliseconds elapsed since
+ the start of the program. The second field is the thread
+ outputting the log statement. The third field is the level of
+ the log statement. The fourth field is the rightmost two
+ components of the logger making the log request. The fifth
+ field (just before the '-') is the nested diagnostic
+ context (NDC). Note the nested diagnostic context may be
+ empty as in the first two statements. The text after the '-'
+ is the message of the statement.
+
+ Although both APIs are conceptually similar, the log4j API is
+ significantly more flexible and offers many more features, too
+ numerous to be listed here. You will discover that the
+ additional features and flexibility turn out to be
+ indispensable in the context of a mission-critical
+ application.
+ The open and collaborative way in which log4j is developped
+ ensures that it continues to preserve and even widen its
+ competitive edge. At some point, input from bright developers
+ from all over the world is bound to make a difference.
+ Lggers lie at the heart of log4j. Loggers define a hierarchy and give
+ the programmer run-time control on which statements are
+ printed or not.
+ Loggers are assigned levels. A log statement is printed
+ depending on its level and its logger.
+ Make sure to read the log4j manual
+ for more information.
+ Log behavior can be set using configuration files which are parsed
+ at runtime. Using configuration files the programmer can define
+ loggers and set their levels.
+ The Configuration files can be specified in XML. See
+ See the various Layout and Appender components for specific
+ configuration options.
+ In addition to configuration files, the user may disable all
+ messages belonging to a set of levels. See next item.
+ For some logger incurs the cost of constructing the message parameter, that is
+ converting both integer If you are worried about speed, then write This way you will not incur the cost of parameter
+ construction if debugging is disabled for logger
+ Yes, there are. You can name loggers by locality. It turns out
+ that instantiating a logger in each class, with the logger name
+ equal to the fully-qualified name of the class, is a useful and
+ straightforward approach of defining loggers. This approach has
+ many benefits:
+ However, this is not the only way for naming loggers. A
+ common alternative is to name loggers by functional
+ areas. For example, the "database" logger, "RMI"
+ logger, "security" logger, or the "XML" logger.
+ You may choose to name loggers by functionality and
+ subcategorize by locality, as in "DATABASE.com.foo.some.package.someClass" or
+ "DATABASE.com.foo.some.other.package.someOtherClass".
+ You are totally free in choosing the names of your
+ loggers. The log4j package merely allows you to manage your
+ names in a hierarchy. However, it is your responsibility to define
+ this hierarchy.
+ Note by naming loggers by locality one tends to name things by
+ functionality, since in most cases the locality relates closely to
+ functionality.
+ You can easily retrieve the fully-qualified name of a class in a
+ static block for class X, with the statement
+ Here is the suggested usage template: Yes, you can extend the Log4j uses JavaBeans style configuration. Thus, any setter method in Layouts options are also defined by their setter methods. The same goes
+ for most other log4j components.
+ We suggest to just use global file search/replace. You should be able
+ to replace all the "java.util.Logger" references with
+ "org.apache.log4j.Logger", and you should be on your way.
+ If you're on a Win32 platform, we recommend Textpad. You can use the
+ CTRL+SHIFT+O to open all *.java files from a directory including all
+ its sub-directories, and then use the search/replace function to
+ replace in all files, and then CTRL+SHIFT+S to save all. Should take
+ about 60 seconds! :)
+ Yes it is. Setting the Threshold option of any appender
+ extending AppenderSkeleton,
+ (most log4j appenders extend AppenderSkeleton) to filter out all log
+ events with lower level than the value of the threshold
+ option.
+ For example, setting the threshold of an appender to DEBUG
+ also allow INFO, WARN, ERROR and FATAL messages to log along
+ with DEBUG messages. This is usually acceptable as there is
+ little use for DEBUG messages without the surrounding INFO,
+ WARN, ERROR and FATAL messages. Similarly, setting the
+ threshold of an appender to ERROR will filter out DEBUG, INFO
+ and WARN messages but not ERROR or FATAL messages.
+ This policy usually best encapsulates what the user
+ actually wants to do, as opposed to her mind-projected
+ solution.
+ See examples/sort4.lcf for an example threshold
+ configuration. If you must filter events by exact level match, then you can
+ attach a LevelMatchFilter
+ to any appender to filter out logging events by exact level match.
+ The NT Event Viewer relies on message resource DLLs
+ to properly view an event message. The NTEventLogAppender.dll
+ contains these message resources, but that DLL must be copied
+ to %SYSTEMROOT%\SYSTEM32 for it to work properly.
+ Unfotunately, the logger names are hardcoded within the
+ message resource DLL (see previous question about
+ NTEventLogAppender), so there isn't any easy way to override
+ those dynamically... in fact, I don't think it's possible to
+ do it, as you'd have to modify the DLL resources for every
+ application. Since most native applications don't use the
+ Logger column anyway...
+
+ The suggested approach depends on your design requirements. If you or
+ your organization has no constraints on the use of Java in JSP pages,
+ simply use log4j normally in
+ However, if your design calls for a minimum amount of Java in your JSP
+ pages, consider using the
+ Log Taglib
+ from the Jakarta Taglibs project. It provides logging JSP tags that invoke
+ log4j.
+ Many developers are confronted with the problem of
+ distinguishing the log output originating from the same class
+ but different client requests. They come up with ingenious
+ mechanisms to fan out the log output to different files. In
+ most cases, this is not the right approach.
+ It is simpler to use a nested diagnostic context
+ (NDC). Typically, one would NDC.push() client
+ specific information, such as the client's hostname, ID or any
+ other distinguishing information when starting to handle the
+ client's request. Thereafter, log output will automatically
+ include the nested diagnostic context so that you can
+ distinguish logs from different client requests even if they
+ are output to the same file.
+ See the For select applications, such as virtual hosting
+ web-servers, the NDC solution is not sufficient. As of version
+ 0.9.0, log4j supports multiple hierarchy trees. Thus, it is
+ possible to log to different targets from the same logger
+ depending on the current context.
+ It is quite nontrivial to define the semantics of a
+ "removed" logger escecially if it is still referenced by the
+ user. Future releases may include a remove method in
+ the Logger class. You may have each process log to a
+ The timestamp is created when the logging event is created.
+ That is so say, when the Timestamps are stored in UTC format inside the
+ event. Consequently, when displayed or written to a log file,
+ timestamps appear in the same timezone as the host displaying
+ or creating the logfile. Note that because the clocks of
+ various machines may not be synchronized, there may be
+ timestamp inconsistencies between events generated on
+ different hosts.
+ The short answer: the log4j classes and the properties file
+ are not within the scope of the same classloader.
+ The long answer (and what to do about it): J2EE or Servlet
+ containers utilize Java's class loading system. Sun changed
+ the way classloading works with the release of Java 2. In
+ Java 2, classloaders are arranged in a hierarchial
+ parent-child relationship. When a child classloader needs to
+ find a class or a resource, it first delegates the request to
+ the parent.
+ Log4j only uses the default So, if you're having problems, try loading the class or
+ resource yourself. If you can't find it, neither will
+ log4j. ;)
+ Yes. Both the DOMConfigurator and the PropertyConfigurator support
+ automatic reloading through the Because the Contrary to the GNU Public License (GPL) the Apache
+ Software License does not make any claims over your
+ extensions. By extensions, we mean totally new code that
+ invokes existing log4j classes. You are free to do
+ whatever you wish with your proprietary log4j extensions.
+ In particular, you may choose to never release your extensions
+ to the wider public.
+ We are very careful not to change the log4j client API so
+ that newer log4j releases are backward compatible with
+ previous versions. We are a lot less scrupulous with the
+ internal log4j API. Thus, if your extension is designed to
+ work with log4j version Thus, you will be forced to spend precious resources in
+ order to keep up with log4j changes. This is commonly referred
+ to as the "stupid-tax." By donating the code and making it
+ part of the standard distribution, you save yourself the
+ unnecessary maintenance work.
+ If your extensions are useful then someone will eventually
+ write an extension providing the same or very similar
+ functionality. Your development effort will be wasted. Unless
+ the proprietary log4j extension is business critical, there is
+ little reason for not donating your extensions back to the
+ project.
+ Write a test case for your contribution. There is nothing more irritating than finding the bugs
+ in debugging (i.e. logging) code. Writing a test case
+ takes some effort but is crucial for a widely used library
+ such as log4j. Writing a test case will go a long way in
+ earning you the respect of fellow developers. See the
+ tests/ directory for exiting test cases.
+ Stick to the existing indentation style even if you hate it. Alternating between indentation styles makes it hard to
+ understand the source code. Make it a little harder on
+ yourself but easier on others.
+ Log4j has adopted a rather conservative approach by
+ following the Code Conventions
+ for the JavaTM Programming Language. We use 2 (two)
+ spaces for indentation and no tabs.
+ Please do not both modify the code and change the
+ indentation in a single commit. If you change the code and reformat it at the same time
+ and then commit, the commit notification message will be
+ hard to read. It will contain many diffs associated with
+ the reformatting in addition to logical changes.
+ If you must reformat and change the code, then perform
+ each step separately. For example, reformat the code and
+ commit. Following that, you can change the logic and
+ commit. The two steps can be performed in the reverse
+ order just as well. You can first change the logic and
+ commit and only later reformat and commit.
+ Make every effort to stick to the JDK 1.1 API. One of the important advantages of log4j is its
+ compatibility with JDK 1.1.x.
+ Always keep it simple, small and fast when
+ possible. It's all about the application not about logging. Identify yourself as a contributor at the top of the
+ relevant file.
+ Take responsibility for your code. Authoring software is very much like running a marathon. It
+ takes time and endurance.
+ Did we mention sticking with the indentation style? Did we mention writing test cases? There are several reasons this can occur:
+ It is possible, but rarely appropriate. The
+ request is commonly for a level named something like "audit"
+ that doesn't obviously fit in the progression "trace", "debug",
+ "info", "warn", "error" and "fatal". In that case, the request
+ for a level is really a request for a mechanism to specify
+ a different audience. The appropriate mechanism is to use a distinct
+ logger name (or tree) for "audit" related messages.
- Copyright © 2000-2002 The Apache Software Foundation. All
+ Copyright © 2000-2002 The Apache Software Foundation. All
rights reserved. This software is published under the terms of
- the Apache Software License version 1.1, a copy of which has
- been included in the LICENSE.txt file shipped with the log4j
+ the Apache Software License version 2.0, a copy of which has
+ been included in the LICENSE file shipped with the log4j
distribution. This document is based on the article "Log4j
delivers control over logging" published in November 2000
- edition of JavaWorld. However, the
- present article contains more detailed and up to date
- information. The short manual also borrows some text from the
- book "log4j: the Manual" by the same author (yours truly).
-
+ edition of JavaWorld. However, the present article contains more
+ detailed and up to date information. The present short manual
+ also borrows some text from "The
+ complete log4j manual" by the same author (yours
+ truly). Inserting log statements into code is a low-tech method for
debugging it. It may also be the only way because debuggers are not
always available or applicable. This is usually the case for
-multithreaded applications and distributed applications at large.
+multithreaded applications and distributed applications at large. Experience indicates that logging was an important component of the
development cycle. It offeres several advantages. It provides precise
@@ -68,9 +77,9 @@ As Brian W. Kernigan and Rob Pike put it in their truly excellent
+ As Brian W. Kernighan and Rob Pike put it in their truly excellent
book "The Practice of Programming"
Logging does have its drawbacks. It can slow down an
application. If too verbose, it can cause scrolling blindness. To
alleviate these concerns, log4j is designed to be reliable, fast and
extensible. Since logging is rarely the main focus of an application,
-log4j API strives to be simple to understand and to use.
+the log4j API strives to be simple to understand and to use. Loggers are named entities. Logger names are case-sensitive and
-they follow the hierarchical naming rule:
+ Loggers are named entities. Logger names are case-sensitive and
+they follow the hierarchical naming rule:
A logger is said to be an ancestor of another
+ For example, the logger named The root logger resides at the top of the logger hierarchy. It
-is exceptional in two ways:
+is exceptional in two ways:
Invoking the class static Logger.getRootLogger
+href="apidocs/org/apache/log4j/Logger.html#getRootLogger()">Logger.getRootLoggerFrequently Asked Questions about log4j
-
-Ceki Gülcü and Chris Taylor
-May 2002
-
-
-
-
-debug method
-expecting a String array as one of its parameters?
-What is log4j?
-
-log4j is a tool to help the programmer output log statements to a
-variety of output targets.
-
-Is log4j a reliable logging system?
-
-No. log4j is not reliable. It is a best-effort and fail-stop
-logging system.
-
-What are the prerequisites for log4j?
-
-
-
-
-
-org.apache.log4j.net.SMTPAppender relies
- on the JavaMail
- API. It has been tested with JavaMail API version 1.2. The
- JavaMail API requires the JavaBeans
- Activation Framework package.
-
- org.apache.log4j.net.JMSAppender requires
- the presence of the JMS API as well as JNDI.
-
-
- Is there example code for using log4j?
-
-examples/ directory.
-
-What are the features of log4j?
-
-
-
-
-
-java.io.OutputStream, java.io.Writer,
- a remote server using TCP, a remote Unix Syslog daemon, to a
- remote listener using JMS, to the NT EventLog or even send e-mail.
-
- Is log4j thread-safe?
-
-Yes, log4j is thread-safe.
-
-What does log output look like?
-
-The log output can be customized in many ways. Moreover, one can completely
-override the output format by implementing one's own Layout.
-
-
-176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse order.
-225 [main] INFO examples.SortAlgo - Entered the sort method.
-262 [main] DEBUG SortAlgo.OUTER i=1 - Outer loop.
-276 [main] DEBUG SortAlgo.SWAP i=1 j=0 - Swapping intArray[0] = 1 and intArray[1] = 0
-290 [main] DEBUG SortAlgo.OUTER i=0 - Outer loop.
-304 [main] INFO SortAlgo.DUMP - Dump of interger array:
-317 [main] INFO SortAlgo.DUMP - Element [0] = 0
-331 [main] INFO SortAlgo.DUMP - Element [1] = 1
-343 [main] INFO examples.Sort - The next log statement should be an error message.
-346 [main] ERROR SortAlgo.DUMP - Tried to dump an uninitialized array.
- at org.log4j.examples.SortAlgo.dump(SortAlgo.java:58)
- at org.log4j.examples.Sort.main(Sort.java:64)
-467 [main] INFO examples.Sort - Exiting main method.
-
-
-What are Loggers?
-
-Lggers lie at the heart of log4j. Loggers define a hierarchy and give
-the programmer run-time control on which statements are
-printed or not.
-
-How can I change log behavior at runtime?
-
-PropertyConfigurator defines a particular format
-of a configuration file. See also the examples/Sort.java
-example and associated configuration files.
-
-log4j.dtd and
-org.log4j.xml.DOMConfigurator for more details.
-
-What is the fastest way of (not) logging?
-
-l, writing,
- l.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
-
-
-i and entry[i] to a
-String, and concatenating intermediate strings. This, regardless of
-whether the message will be logged or not.
-
-
- if(l.isDebugEnabled()) {
- l.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
- }
-
-
-l. On the other
-hand, if the logger is debug enabled, you will incur the cost of
-evaluating whether the logger is enabled or not, twice: once in
-debugEnabled and once in debug. This is an
-insignificant overhead since evaluating a logger takes less than 1%
-of the time it takes to actually log a statement.
-
-Are there any suggested ways for naming
-loggers?
-
-
-
-
-
-How do I get the fully-qualified name of a class
-in a static block?
-
-X.class.getName(). Note that X is the class
-name and not an instance. The X.class statement does
-not create a new instance of class X.
-
-
-package a.b.c;
-
-public class Foo {
- static Logger logger = Logger.getLogger(Foo.class);
- ... other code
-
-}
-
-
-Can the log output format be customized?
-
-Layout
-class to create you own customized log format. Appenders can be
-parameterized to use the layout of your choice.
-
-Can the outputs of multiple client request go to
-different log files?
-
-Many developers are confronted with the problem of distinguishing the
-log output originating from the same class but different client
-requests. They come up with ingenious mechanisms to fan out the log
-output to different files. In most cases, this is not the right
-approach.
-
-NDC and the PatternLayout classes
-for more information. The NumberCruncher example shows
-how the NDC can be used to distinguish the log output from multiple
-clients even if they share the same log file.
-
-What are the configurable options for
-FooBarAppender?
-
-Log4j uses JavaBeans style configuration.
-
-FooBarAppender corresponds
-to a configurable option. For example, in RollingFileAppender
-the setMaxBackupIndex(int
-maxBackups) method corresponds to the maxBackupIndex
-option. The first letter of the option can be upper case, i.e.
-MaxBackupIndex and maxBackupIndex are
-equivalent but not MAXBACKUPIndex nor
-mAXBackupIndex.
-
-Logger instances seem to be create only. Why isn't
-there a method to remove logger instances?
-
-It is quite nontrivial to define the semantics of a "removed" logger
-which is still referenced by the user. Future releases may
-include a remove method in the Logger class.
-
-Is it possible to direct log output to
-different appenders by level?
-
-How do I get multiple process to log to the same file?
-
-SocketAppender.
-The receiving
-SocketServer
-(or
-SimpleSocketServer)
-can receive all the events and send them to a single
-log file.
-
-If I have many processes across multiple hosts
-(possibly across multiple timezones) logging to the same file using the
-method above, what happens to timestamps?
-
-debug, info, warn,
-error or fatal method is invoked.
-This is unaffected by the time at which they may arrive at a remote
-socket server. Since the timestamps are stored in UTC format inside
-the event, they all appear in the same timezone as the host creating the
-logfile. Since the clocks of various machines may not be synchronized,
-this may account for time interval inconsistencies between events generated
-on different hosts.
-
-Why can't Log4J find my properties file in a J2EE
-or WAR application?
-
-The short answer: the Log4J classes and the properties file are not
-within the scope of the same classloader.Class.forName() mechanism
-for loading classes. Resources are handled similarly. See the
-documentation for java.lang.ClassLoader for more details.
-
-Is there a way to get Log4J to
-automatically reload a configuration file if it changes?
-
-configureAndWatch APIs.
-See the API documentation for more details.
-
-What does the Windows NT Event
-Viewer complain about missing descriptions for my event messages when
-I use the NTEventLogAppender?
-
-Why can't I map my logger names
-to the loggers that appear in the NT Event Log when I use the
-NTEventLogAppender?
-
-Why should I donate my extensions to log4j back to the
-project?
-
-Contrary to the GNU Public License (GPL) the Apache Software License
-does not make any claims over your extensions. By extensions, we mean
-totally new code that invokes existing log4j classes. You are free
-to do whatever you wish with your proprietary log4j extensions.
-In particular, you may choose to never release your extensions to the
-wider public.
-
-n, then when log4j release version n+1 comes
-out, you will probably need to adapt your proprietary extensions to
-the new release.
-
-Thus, you will be forced to spend precious resources in order to keep
-up with log4j changes. This is commonly referred to as the
-"stupid-tax." By donating the code and making it part of the standard
-distribution, you save yourself the unnecessary maintenance work.
-
-What should I keep in mind when contributing
-code?
-
-
-
-
-
-Where can I find the latest distribution of log4j?
-
-
-
-
-
diff --git a/docs/HISTORY b/docs/HISTORY
deleted file mode 100644
index 6f2a35a5eb..0000000000
--- a/docs/HISTORY
+++ /dev/null
@@ -1,1519 +0,0 @@
-
-
- [*] Changes that are 100% compatible with existing client code.
- [**] Changes that requiring little or no modification to existing
- client code.
- [***] Changes requiring important modifications to existing client code.
-
- May, 2002
-
- - Release of version 1.2
-
- - Fixed bug #8527. A closed TelnetAppender would continue waiting
- for connections even if its ServerSocket was closed. This caused
- the TelnetSocket to sit in a loop and complain about the closed
- socket. [*]
-
- - AsyncAppender throws NullPointerException problem. The bug was actually in
- AppenderSkeleton. See bug #5444 details. [*]
-
- - Added support for recursive variable substiuton as requested by
- Eric Chastan. [*]
-
- - SocketNode now used a BufferedInputStream as suggested by Kok Chong
- in bug report #3933. [*]
-
- - Fixed a problem with DailiyRollingAppender which would not
- correctly compute the rollover period in certain timezones. See bug
- report #7550. [*]
-
- - Fixed documentation bug #2726 in FAQ.html. [*]
-
- - In WriterAppender, fixed bug #2383 by adding a flush statement in the
- writeFooter method. [*]
-
- - In XMLLayout, Fixed bug #7550 by escaping the method attribute. The
- XMLLayout also outputs each item of a stack trace in a separate
- line. [*]
-
- - Fixed bug #5932 as suggested by Heikki Linnakangas. The
- LoggingEvent.getMDCCopy method now clones the MDC instead of just
- referencing it. [*]
-
- (rc1)
-
- - The ANT build script was modified to use jar files specified in
- the build.properties file instead of the CLASSPATH environment
- variable. The build.properties file depends on local paths and is
- supplied by the user. The build.properties.sample file is included
- in the distribution. The build.sh and build.bat scripts have
- been removed. This is the way many other jakarta projects build their
- projects. The jar files in the dist/lib directory were also removed
- since they are no longer used. [*]
-
- - The DOMConfigurator now interprets the string after the '#'
- character in the value attribute within the Log4j troubleshooting
-
- Ceki Gülcü Paul Glezen
-
-
-
February 2002
-
-
-
-
- log4j tells me to initialize properly.
-
- Logging output is written to a target by using an appender. If no
- appenders are attached to a category nor to any of its ancestors, you
- will get the following message when trying to log:
-
-log4j: No appenders could be found for category (some.category.name).
-log4j: Please initialize the log4j system properly.
-
-
- Duplicates in log4j output.
System.out target to the root
- category. A, to the root
- category, all other categories will inherit A
- as an appender. Thus, if you add A to a
- category, say C, then an enabled statement of
- category C, will print to A twice,
- once because A is in root and once because it
- is in C. Options are not parsed correctly.
-
- java.util.Properties class to read in the
- configuration file. This class preserves spaces in
- options. For example,
-fruit=orange
-
-is returned as an option having the key "fruit" and the
- value "orange "."orange ", are due to
- invisible spaces at the end of the example shown above. Thus, some of
- the options might not be interpreted correctly due to trailing
- spaces. Caller location information is printed as a "?"
- character.
-
- Location information is extracted automatically by the PatternLayout
- conversion patterns %C, %F, %M and %L. However, some just-in-time
- (JIT) compilers make it impossible to extract location information. It
- is also possible that the compiler that generated the byte code may
- have omitted the LineNumber table as is done by -O option of javac
- and jikes. Category need supply their
- fully qualified class name to the Category.log method or
-to Category.forcedLog methods so that the caller location
-information can be extracted correctly.com.foo.BarCategory
- from the com.foo.BarCategoryTest class will
- not yield the correct caller information. To circumvent
- this "bug", either perform the tests from a class with a
- different name or add a dot to the fully qualified name of
- the extending class that you supply to
- Category.log to
- Category.forcedLog methods. For the
- com.foo.BarCategory example, supply the
- string "com.foo.BarCategory.".
-
- ClassCastException when
-instantiating a Category subclasses.ClassCastException
- Category c1 = Category.getInstance("bad");
- MyCategory c2 = (MyCategory) MyCategory.getInstance("bad");
-
-
-where MyCategory is a subclass of
-Category. The problem occurs because the second
-getInstance invocation will retrieve the category created
-in the fist invocation. This instance is a Category
-object and cannot be cast to MyCategory.PropertyConfigurator will
- create and configure
- org.apache.log4j.Category objects. Thus, if
- you try to instantiate a category subclass for an already
- existing category, and try to cast it to the subclass
- type, you will systematically get a
- ClassCastException.PropertyConfigurator admits the
- log4j.categoryFactory key. The value of this
- key will be used as the factory to invoke when
- instantiating Category objects.
-
- DOMConfigurator has a finer grain
- method for setting the class of the category object to instantiate.
-
-
-
-
-Log4j class not found/defined
-
-
-
-jre/lib/ext directory
-but place user-defined extensions to log4j in the application
-classloader classpath, log4j configurators will not find them.
-
-IOException:
-connection refused.
-
--r option when starting
-the daemon. Or more precisely:
-
-
-
-
-root user
-/etc/rc/init.d/syslog
-
-case "$1" in
- start)
- echo -n "Starting system logger: "
- daemon syslogd -r
-
-
-/etc/rc/init.d/syslog restart
-
-log4j:WARN No such property [xyz] in some.appender.or.layout
-
-JSR47 vs. log4j
-
-On Parents and Children
-
-"foo" knows about
-"foo.bar1" and "foo.bar2". However,
-"foo.bar1" has no links to its parent "foo".
-
-
-
-
-wombat, JSR47 traverses the tree below
-wombat. In other words, the levels for all the loggers
-descending from wombat are overwritten. This can be a
-very expensive operation for large trees. In particular, for the most
-common case where one sets the level of the root logger. However,
-performance is not the point I am trying to make.
-
-Bogus Levels
-
-ALL, SEVERE,
-WARNING, INFO, CONFIG,
-FINE, FINER, FINEST and
-OFF. Experience shows that the levels ALL
-and OFF are never needed. The SEVERE and
-CONFIG levels are unique to JSR47.
-
-FINE,
-FINER, FINEST could seem like a good
-idea. However, you will soon discover that even when by yourself, it
-is hard to decide when to use which level. It is plain impossible in
-groups.
-
-FATAL, ERROR, WARN,
-INFO and DEBUG.
-
-Limited functionality
-
-PatternLayout. JSR47 offers the much weaker
-SimpleFormatter as an alternative.
-
-Other differences
-
-
-
-
-
-java.util.logging is under the java.*
-namespace, when running under JDK 1.3, you will systematically
-encounter:
-
-Exception in thread "main" java.lang.ExceptionInInitializerError: java.lang.SecurityException: Prohibited package name: java.util.logging
- at java.lang.ClassLoader.defineClass(ClassLoader.java:477)
- at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
- at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
- at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
- at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
- at java.security.AccessController.doPrivileged(Native Method)
- at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
- at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
- at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
- at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
- at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
-
-
-java.* or javax.* namespaces violates Sun's
-trademark on Java. Without explicit permission from Sun, such software
-remains under the threat of litigation.
-
-Error Handling
-
-In JSR 47 when an error occurs then either a
-RunTimeException is thrown to the user or (in handlers
-only) an internal field is set. In the first case, the
-RunTimeException will cause your application to crash. In
-the latter case, you can retrieve the last caught exception in the
-handler by querying the getException method of that
-handler. The former is totally unacceptable while the latter is
-impractical.
-
-ErrorHandler. This ErrorHandler is invoked
-by the appender whenever a handler-specific error occurs. By default,
-log4j appenders are associated with an
-OnlyOnceErrorHandler which emits a message on the console
-for the first error in an appender and ignoring all following errors.
-
-ErrorHandler can implement an arbitrary error
-handling policy. For example, after a failure to write to a database a
-JDBCAppender can be redirected to fall back on a
-FileAppender. This functionality is supported in XML
-configuration files. You do not need to change a single line of client
-code.
-
-Performance
-
-Adding Conversion Characters to PatternLayout
-
- "Paul Glezen"
-
- January 2001
-
-Abstract
-
-PatternLayout
-class.
-
-Contents
-
-
-
-
-
-Introduction
-
-The Case Study
-The case study was developed in a CORBA environment in which the
-following information for each log entry was needed. The letters in
-parenthesis represent the corresponding character to be used by the
-PatternLayout
-class for formatting.
-
-
-
-PatternLayout
-already defines both "C" and "c" for class name and category name respectively.
-
-A Peek Under the Hood
-
-
-Category
-object. Let's say the info method was invoked.
-info does is to check if logging has
-been turned off entirely for the info level. If so, it returns
-immediately. We'll assume for this scenario that logging has not
-been turned off for the info level.
-info compares the
-Priority
-level for this category against Priority.INFO. Assuming
-the priority warrants logging the message, the category instantiates a
-LoggingEvent
-object populated with information available for logging.
-Category instance passes the LoggingEvent
-instance to all its
-Appender
-implementations.
-Appender implementations should have
-an associated subclass of
-Layout.
-The Layout subclass is passed the LoggingEvent
-instance and returns the event's information formatted in a
-String according to the configuration of the Layout.
-Layout subclass is
-PatternLayout,
-the format of the event's information is determined by a character sequence
-similar to the C language library's printf routine.
-PatternLayout delegates the parsing of this character sequence to a
-PatternParser
-instance.
-PatternLayout was constructed, it created a
-PatternParser to tokenize the character sequence. Upon
-recognizing a token, the PatternParser constructs an appropriate
-PatternConverter
-subclass, passing it formatting information from the token. Often the
-PatternConverter subclasses are implemented as static inner
-classes of PatternParser. The parse method of
-the PatternParser returns a linked list of these
-PatternConverter subclasses.
-PatternLayout.format() passes the LoggingEvent
-to each PatternConverter subclass in the linked list. Each link
-in the list selects a particular item from the LoggingEvent,
-converts this item to a String in the proper format and appends
-it to a StringBuffer.
-format method returns the resulting String
-to the Appender for output.
-
-
-org.apache.log4j.PatternLayout
-org.apache.log4j.Category
-org.apache.log4j.spi.CategoryFactory
-org.apache.log4j.spi.LoggingEvent
-org.apache.log4j.helpers.PatternParser
-org.apache.log4j.helpers.PatternConverter
-
-The Process
-Below are steps required to add additional attributes available
-for logging by extending log4j. This will allow you to specify
-their output formats in the same manner as those provided by the
-PatternLayout class. The steps are numbered for
-reference only. It makes no difference in which order they are
-followed.
-PatternLayout symbol for each one before you begin. Be
-sure to consult the PatternLayout documentation to ensure
-the symbols you select are not already in use.
-1. Extending
-
-Extending the LoggingEventLoggingEvent class should be one of the
-trivial steps. All that is needed in the extension is the addition
-of public data members representing the new attributes and a new
-constructor to populate them.
-
-
-
-
-import org.apache.log4j.Category;
-import org.apache.log4j.Priority;
-import org.apache.log4j.spi.LoggingEvent;
-
-public class AppServerLoggingEvent extends LoggingEvent
- implements java.io.Serializable
-{
- public String hostname;
- public String component;
- public String server;
- public String version;
-
- public AppServerLoggingEvent( String fqnOfCategoryClass,
- AppServerCategory category,
- Priority priority,
- Object message,
- Throwable throwable)
- {
- super( fqnOfCategoryClass,
- category,
- priority,
- message,
- throwable );
-
- hostname = category.getHostname();
- component = category.getComponent();
- server = category.getServer();
- version = category.getVersion();
- }
-}
-
-Category
-subclass will contain most of the information necessary to populate
-the attributes of the LoggingEvent subclass. Extensions
-to LoggingEvent seem no more than a collection of strings
-with a constructor. Most of the work is done by the super class.
-
-2. Extending
-
-Extending the PatternLayoutPatternLayout class should be another
-simple matter. The extension to PatternLayout should
-differ from its parent only in the creation of a
-PatternParser instance. The extended
-PatternLayout should create an extended
-PatternParser class. Fortunately, this task in
-PatternLayout is encapsulated within a single method.
-
-
-
-
-import org.apache.log4j.PatternParser;
-import org.apache.log4j.PatternLayout;
-
-public class AppServerPatternLayout extends PatternLayout
-{
- public AppServerPatternLayout()
- {
- this(DEFAULT_CONVERSION_PATTERN);
- }
-
- public MyPatternLayout(String pattern)
- {
- super(pattern);
- }
-
- public PatternParser createPatternParser(String pattern)
- {
- PatternParser result;
- if ( pattern == null )
- result = new AppserverPatternParser( DEFAULT_CONVERSION_PATTERN );
- else
- result = new AppServerPatternParser ( pattern );
-
- return result;
- }
-}
-
-3. Extend
-
-Recall from our peek under the hood that the
-PatternParser and PatternConverterPatternParser does much of its work in its
-parse method. The PatternLayout object
-instantiates a PatternParser object by passing it
-the pattern string. The PatternLayout then invokes the
-parse method of PatternParser to produce
-a linked list of PatternConverter subclass instances.
-It is this linked list of converters that is used to convert an
-event instance into a string used by appenders.
-PatternParser to properly
-interpret formatting characters we wish to add. Fortunately,
-PatternParser has been designed so that only the one
-step in the parsing process differing for each formatting character
-has to be overridden. The grunt work of parsing is still performed
-by the PatternParser.parse() method. Only the
-PatternParser.finalizeConverter method has to be
-overridden. This is the method that decides which
-PatternConverter to create based on a formatting
-character.
-PatternParser,
-AppServerPatternParser, is similar to its super class.
-It uses
-
-
-AppServerPatternParser.
-finalizeConverter method which instantiates
- the appropriate converter for a given format character.
-AppServerPatternParser differs principally by
-dedicating a separate converter type for each logging
-attribute to be formatted.
-Rather than placing switch logic in the converter, like its
-parent class, each converter only converts one format character.
-This means the decision of which converter subclass
-to instantiate is made at layout instantiation time rather
-than in a switch statement at logging time.
-
-
-
-
-import org.apache.log4j.*;
-import org.apache.log4j.helpers.FormattingInfo;
-import org.apache.log4j.helpers.PatternConverter;
-import org.apache.log4j.helpers.PatternParser;
-import org.apache.log4j.spi.LoggingEvent;
-
-public class AppServerPatternParser extends PatternParser
-{
- static final char HOSTNAME_CHAR = 'h';
- static final char SERVER_CHAR = 's';
- static final char COMPONENT_CHAR = 'b';
- static final char VERSION_CHAR = 'v';
-
- public AppServerPatternParser(String pattern)
- {
- super(pattern);
- }
-
- public void finalizeConverter(char formatChar)
- {
- PatternConverter pc = null;
- switch( formatChar )
- {
- case HOSTNAME_CHAR:
- pc = new HostnamePatternConverter( formattingInfo );
- currentLiteral.setLength(0);
- addConverter( pc );
- break;
- case SERVER_CHAR:
- pc = new ServerPatternConverter( formattingInfo );
- currentLiteral.setLength(0);
- addConverter( pc );
- break;
- case COMPONENT_CHAR:
- pc = new ComponentPatternConverter( formattingInfo );
- currentLiteral.setLength(0);
- addConverter( pc );
- break;
- case VERSION_CHAR:
- pc = new VersionPatternConverter( formattingInfo );
- currentLiteral.setLength(0);
- addConverter( pc );
- break;
- default:
- super.finalizeConverter( formatChar );
- }
- }
-
- private static abstract class AppServerPatternConverter extends PatternConverter
- {
- AppServerPatternConverter(FormattingInfo formattingInfo)
- {
- super(formattingInfo);
- }
-
- public String convert(LoggingEvent event)
- {
- String result = null;
- AppServerLoggingEvent appEvent = null;
-
- if ( event instanceof AppServerLoggingEvent )
- {
- appEvent = (AppServerLoggingEvent) event;
- result = convert( appEvent );
- }
- return result;
- }
-
- public abstract String convert( AppServerLoggingEvent event );
- }
-
- private static class HostnamePatternConverter extends AppServerPatternConverter
- {
- HostnamePatternConverter( FormattingInfo formatInfo )
- { super( formatInfo ); }
-
- public String convert( AppServerLoggingEvent event )
- { return event.hostname; }
- }
-
- private static class ServerPatternConverter extends AppServerPatternConverter
- {
- ServerPatternConverter( FormattingInfo formatInfo )
- { super( formatInfo ); }
-
- public String convert( AppServerLoggingEvent event )
- { return event.server; }
- }
-
- private static class ComponentPatternConverter extends AppServerPatternConverter
- {
- ComponentPatternConverter( FormattingInfo formatInfo )
- { super( formatInfo ); }
-
- public String convert( AppServerLoggingEvent event )
- { return event.component; }
- }
-
- private static class VersionPatternConverter extends AppServerPatternConverter
- {
- VersionPatternConverter( FormattingInfo formatInfo )
- { super( formatInfo ); }
-
- public String convert( AppServerLoggingEvent event )
- { return event.version; }
- }
-}
-
-4. Extending
-Extending CategoryCategory and its factory will be more straight
-forward than extending PatternParser and the converters.
-The following tasks are involved in overridding
-Category for our purposes.
-
-
-forcedLog method to ensure that a
- correctly populated instance of
- AppServerLoggingEvent is instantiated rather than
- the default LoggingEvent.
-getInstance method to use our
- CategoryFactory (described in the next step). This will
- require that we hold a static reference to our factory and provide a
- way to initialize it.
-Category: the four new logging attributes
-plus a static AppServerCategoryFactory reference. This is
-pre-initialized to an instance with attributes set to null as a
-precautionary measure. Otherwise the getInstance method
-will result in a null pointer exception if invoked before the
-setFactory method.
-getInstance method simply invokes its parent class
-method that accepts a CategoryFactory reference in
-addition to the category name.
-forcedLog method follows closely the corresponding
-parent class method. The most important difference is the instantiation
-of the AppServerLoggingEvent. A minor yet necessary
-difference is the use of the getRendererMap() method rather
-than accessing the data member directory as in Category.
-Category can do this because the rendererMap
-is package level accessible.
-setFactory method is provided to allow application code
-to set the factory used in the getInstance method.
-
-
-
-
-import org.apache.log4j.Priority;
-import org.apache.log4j.Category;
-import org.apache.log4j.spi.CategoryFactory;
-import org.apache.log4j.spi.LoggingEvent;
-
-public class AppServerCategory extends Category
-{
- protected String component;
- protected String hostname;
- protected String server;
- protected String version;
- private static CategoryFactory factory =
- new AppServerCategoryFactory(null, null, null);
-
- protected AppServerCategory( String categoryName,
- String hostname,
- String server,
- String component,
- String version )
- {
- super( categoryName );
- instanceFQN = "org.apache.log4j.examples.appserver.AppServerCategory";
-
- this.hostname = hostname;
- this.server = server;
- this.component = component;
- this.version = version;
- }
-
- public String getComponent()
- { return (component == null ) ? "" : result; }
-
- public String getHostname()
- { return ( hostname == null ) ? "" : hostname; }
-
- public static Category getInstance(String name)
- {
- return Category.getInstance(name, factory);
- }
-
- public String getServer()
- { return ( server == null ) ? "" : server; }
-
- public String getVersion()
- { return ( version == null ) ? "" : version; }
-
- protected void forcedLog( String fqn,
- Priority priority,
- Object message,
- Throwable t)
- {
- LoggingEvent event = new AppServerLoggingEvent(fqn, this, priority, message, t);
- callAppenders( event );
- }
-
- public void setComponent(String componentName)
- { component = componentName; }
-
- public static void setFactory(CategoryFactory factory)
- { AppServerCategory.factory = factory; }
-
- public void setHostname(String hostname)
- { this.hostname = hostname; }
-
- public void setServer(String serverName)
- { server = serverName; }
-
- public void setVersion(String versionName)
- { version = versionName; }
-}
-
-5. Extending
-
-The last step is to provide an implementation of the
-CategoryFactoryCategoryFactory interface that will correctly
-instantiate our AppServerCategory objects. It
-will obtain the hostname of the machine on which it runs using the
-java.net API. Aside from providing getters and
-setters for the attributes introduced, the only method to
-be implemented is the makeNewCategoryInstance.
-AppServerCategoryFactory
-with getters, setters and comments removed.
-
-
-
-
-import org.apache.log4j.Category;
-import org.apache.log4j.spi.CategoryFactory;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class AppServerCategoryFactory implements CategoryFactory
-{
- protected String hostname;
- protected String server;
- protected String component;
- protected String version;
- protected ResourceBundle messageBundle;
-
- protected AppServerCategoryFactory( String serverName,
- String componentName,
- String versionName )
- {
- try
- {
- hostname = java.net.InetAddress.getLocalHost().getHostName();
- }
- catch ( java.net.UnknownHostException uhe )
- {
- System.err.println("Could not determine local hostname.");
- }
-
- server = serverName;
- component = componentName;
- version = versionName;
- }
-
- public Category makeNewCategoryInstance(String name)
- {
- Category result = new AppServerCategory( name,
- hostname,
- server,
- component,
- version);
- return result;
- }
-}
-
-
-Usage
-We now arrive at how to use what we have created. We must remember to
-initialize log4j by creating an instance of
-AppServerCategoryFactory and passing it to
-AppServerCategory. Once done, we can obtain a
-AppServerCategoryInstance anytime by using the static
-getInstance method of AppServerCategory.
-This will ensure that AppServerLoggingEvent instances
-are generated by the category logging methods.
-
-
-
-
-import org.apache.log4j.*;
-import org.apache.log4j.appserver.AppServerCategory;
-import org.apache.log4j.appserver.AppServerCategoryFactory;
-import org.apache.log4j.appserver.AppServerPatternLayout;
-
-public class test
-{
- private static String formatString =
- "---------------------------------------------------%n" +
- "Time: %d%n" +
- "Host: %h%n" +
- "Server: %s%n" +
- "Component: %b%n" +
- "Version: %v%n" +
- "Priority: %p%n" +
- "Thread Id: %t%n" +
- "Context: %x%n" +
- "Message: %m%n";
-
- public static void main(String[] args)
- {
- AppServerCategoryFactory factory;
- factory = new AppServerCategoryFactory("MyServer", "MyComponent", "1.0");
- AppServerCategory.setFactory( factory );
- Category cat = AppServerCategory.getInstance("some.cat");
-
- PatternLayout layout = new AppServerPatternLayout( formatString );
- cat.addAppender( new FileAppender( layout, System.out) );
-
- cat.debug("This is a debug statement.");
- cat.info("This is an info statement.");
- cat.warn("This is a warning statement.");
- cat.error("This is an error statement.");
- cat.fatal("This is a fatal statement.");
- }
-}
-
-Configurators
-There is one a word of caution concerning the use of configurators that
-may create Category instances (such as
-
-PropertyConfigurator
-and
-
-DOMConfigurator). Since these configurators do not
-know about our extensions, any Category instances they
-create will not be AppServerCategory instances. To
-prevent this problem, any AppServerCategory that one
-might want to be configured through a configurator should be
-instantiated before the configure method is invoked. In this way,
-the configurator will configure the AppServerCategory
-that already exists rather than creating an instance of its super
-class.
-
-Further Enhancements
-There are some other directions in which this log4j extension
-may be enhanced:
-
-
Praise from log4j users
-
-
-Log4J was named as a finalist in the "Most Useful New or Revised Java API/Technology"
-category, and Tomcat 3.2 was named as a finalist in the "Most Innovative Java Product" category.
-
-
-
-
-
-This Java package is probably one of the best and most reliable packages
-around, and really helps development and maintenance of quality software.
-Thanks to all contributors who have made such a good work.
-
-
- This is just a quick note of thanks for publishing
-your article in Javaworld. Log4j is really easy to use. While I was
-initially skeptical of the idea, code like this makes me a believer in
-the concept of Open Source.
-
-
-
-I just recently became aware of log4j and am just now begining to use
-it. I want to thank you and the rest of the log4j development team for
-making this functionality available. You are providing an outstanding
-service to the development community. Please pass my regards on to the
-other team members.
-
-
-
-
-Just thought I'd let you know that I am using your log4j as a part of
-an e-commerce application (www.consumerd.com). I am using
-the XML configuration classes and have to say that I am most
-impressed.
-
-
-
-
-You should see what we've used log4j for at work... I put together
-this Servlet that can interpret SOAP messages and invoke little
-"handlers". Logging is pervasive through out the system, and the
-handler developers can "create" their own Categories dynamically using
-the getInstance method of Category.
-
-
-
-I am using log4j for a project I am currently working on. The
-simplicity and ease with which new appenders can be written makes it
-one of the best logging systems I have ever used.
-
-
-
-Thank you for writing this incredibly effective piece of software. You
-have made my and my team's lives much easier.
-
-
-
-Thank you so much for developing such a
-sleek package. I think it's going to be a part of many of my projects in
-the future :)
-
-
-
-Thank you very much for your great work on log4j, which is really
-powerful and flexible logging system. Log4j is now playing an
-important role in our project.
-
-
-
- Thank you and your team giving us a excellent tool to
-help us to develop our Java applications. After evaluation, our team
-is ready to use log4j as our eCare product's diagnostic strategy.
-
-
-Was trying to use the log4j tracer ... great job, by the way !
-
-
-
-
-Hooray, log4j! It's now all over my current project, and my colleagues
-were pleasantly surprised at the ease of debugging. I gave them my
-jarfile, it didn't work, I said "oh, just change this configuration
-file" and presto, logging to a file. They're happy.
-
-
-
-I really dig your log4j package... just started using it on our linux
-and os390 boxes for the java servlets we run in websphere. Still
-trying to get the hang of it properly, but what I do have working is
-working great. (Not to mention your makefile tutorial which has
-improved my life significantly! :-)
-
-
-
-Thanks for providing log4j: it's a very useful package.
-
-
-
-I just started using log4j v.0.8.1. It is quite what I was looking for.
-
-
-
-I just wanted to thank you for log4j which is a great piece of software!
-
-
-
-
-Thanks for making log4j available.
-I like the changes in v0.8 and am using it in all my java projects.
-
-
-
-First congratulation for your great job on the Log mechanism log4j,
-it's really valuable.
-
-
Just a few remarks to your log4j Logging-Tool. First
-of all, in my opinion, it is exactly what many Java programmers need:
-A small but very useful tool complementing the debugger ;-) The logs
-help me to debug results generated on a distant client.
-
diff --git a/examples/.cvsignore b/examples/.cvsignore
deleted file mode 100644
index f590ca415d..0000000000
--- a/examples/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-doc-files
\ No newline at end of file
diff --git a/examples/MyPatternLayout.java b/examples/MyPatternLayout.java
index eba1787c66..8cb563da8e 100644
--- a/examples/MyPatternLayout.java
+++ b/examples/MyPatternLayout.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package examples;
@@ -46,9 +56,9 @@ PatternParser createPatternParser(String pattern) {
public
static void main(String[] args) {
Layout layout = new MyPatternLayout("[counter=%.10#] - %m%n");
- Category cat = Category.getInstance("some.cat");
- cat.addAppender(new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT));
- cat.debug("Hello, log");
- cat.info("Hello again...");
+ Logger logger = Logger.getLogger("some.cat");
+ logger.addAppender(new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT));
+ logger.debug("Hello, log");
+ logger.info("Hello again...");
}
}
diff --git a/examples/MyPatternParser.java b/examples/MyPatternParser.java
index ea19c6af53..b65746bec8 100644
--- a/examples/MyPatternParser.java
+++ b/examples/MyPatternParser.java
@@ -1,13 +1,22 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package examples;
-import org.apache.log4j.*;
import org.apache.log4j.helpers.FormattingInfo;
import org.apache.log4j.helpers.PatternConverter;
import org.apache.log4j.helpers.PatternParser;
diff --git a/examples/NumberCruncher.java b/examples/NumberCruncher.java
index 3a6e85cec3..84ba303c28 100644
--- a/examples/NumberCruncher.java
+++ b/examples/NumberCruncher.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package examples;
diff --git a/examples/NumberCruncherClient.java b/examples/NumberCruncherClient.java
index 0d6e96bb26..4f58271bc4 100644
--- a/examples/NumberCruncherClient.java
+++ b/examples/NumberCruncherClient.java
@@ -1,17 +1,24 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package examples;
-import java.rmi.Remote;
-import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.rmi.Naming;
-import java.util.Vector;
import java.io.*;
/**
diff --git a/examples/NumberCruncherServer.java b/examples/NumberCruncherServer.java
index d2eec74ee9..e981243d64 100644
--- a/examples/NumberCruncherServer.java
+++ b/examples/NumberCruncherServer.java
@@ -1,20 +1,28 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package examples;
-import java.rmi.Remote;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.rmi.Naming;
import java.util.Vector;
-
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
import org.apache.log4j.PropertyConfigurator;
@@ -52,10 +60,10 @@
*/
public class NumberCruncherServer extends UnicastRemoteObject
implements NumberCruncher {
+ private static final long serialVersionUID = 2626753561969426769L;
- static Category cat = Category.getInstance(
- NumberCruncherServer.class.getName());
+ static Logger logger = Logger.getLogger(NumberCruncherServer.class);
public
NumberCruncherServer() throws RemoteException {
@@ -66,7 +74,7 @@ int[] factor(int number) throws RemoteException {
// The client's host is an important source of information.
try {
- NDC.push(this.getClientHost());
+ NDC.push(getClientHost());
}
catch(java.rmi.server.ServerNotActiveException e) {
// we are being called from same VM
@@ -79,7 +87,7 @@ int[] factor(int number) throws RemoteException {
// contained in cookies.
NDC.push(String.valueOf(number));
- cat.info("Beginning to factor.");
+ logger.info("Beginning to factor.");
if(number <= 0) {
throw new IllegalArgumentException(number+" is not a positive integer.");
}
@@ -93,10 +101,10 @@ else if(number == 1)
// It is bad practice to place log requests within tight loops.
// It is done here to show interleaved log output from
// different requests.
- cat.debug("Trying to see if " + i + " is a factor.");
+ logger.debug("Trying to see if " + i + " is a factor.");
if((n % i) == 0) {
- cat.info("Found factor "+i);
+ logger.info("Found factor "+i);
factors.addElement(new Integer(i));
do {
n /= i;
@@ -108,7 +116,7 @@ else if(number == 1)
}
if(n != 1) {
- cat.info("Found factor "+n);
+ logger.info("Found factor "+n);
factors.addElement(new Integer(n));
}
@@ -140,7 +148,7 @@ void usage(String msg) {
public static
void delay(int millis) {
- try{Thread.currentThread().sleep(millis);}
+ try{Thread.sleep(millis);}
catch(InterruptedException e) {}
}
@@ -153,10 +161,10 @@ public static void main(String[] args) {
try {
ncs = new NumberCruncherServer();
Naming.rebind("Factor", ncs);
- cat.info("NumberCruncherServer bound and ready to serve.");
+ logger.info("NumberCruncherServer bound and ready to serve.");
}
catch(Exception e) {
- cat.error("Could not bind NumberCruncherServer.", e);
+ logger.error("Could not bind NumberCruncherServer.", e);
return;
}
NumberCruncherClient.loop(ncs);
diff --git a/examples/Sort.java b/examples/Sort.java
index a4a9ac8151..7b97225058 100644
--- a/examples/Sort.java
+++ b/examples/Sort.java
@@ -1,9 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package examples;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
/**
Example code for log4j to viewed in conjunction with the {@link
diff --git a/examples/SortAlgo.java b/examples/SortAlgo.java
index a5a3f53e2f..dde9ce811c 100644
--- a/examples/SortAlgo.java
+++ b/examples/SortAlgo.java
@@ -1,7 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package examples;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
/**
@@ -16,11 +32,11 @@
public class SortAlgo {
final static String className = SortAlgo.class.getName();
- final static Category CAT = Category.getInstance(className);
- final static Category OUTER = Category.getInstance(className + ".OUTER");
- final static Category INNER = Category.getInstance(className + ".INNER");
- final static Category DUMP = Category.getInstance(className + ".DUMP");
- final static Category SWAP = Category.getInstance(className + ".SWAP");
+ final static Logger LOG = Logger.getLogger(className);
+ final static Logger OUTER = Logger.getLogger(className + ".OUTER");
+ final static Logger INNER = Logger.getLogger(className + ".INNER");
+ final static Logger DUMP = Logger.getLogger(className + ".DUMP");
+ final static Logger SWAP = Logger.getLogger(className + ".SWAP");
int[] intArray;
@@ -29,7 +45,7 @@ public class SortAlgo {
}
void bubbleSort() {
- CAT.info( "Entered the sort method.");
+ LOG.info( "Entered the sort method.");
for(int i = intArray.length -1; i >= 0 ; i--) {
NDC.push("i=" + i);
diff --git a/examples/Trivial.java b/examples/Trivial.java
index 0f97056295..99e9978125 100644
--- a/examples/Trivial.java
+++ b/examples/Trivial.java
@@ -1,8 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package examples;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.NDC;
@@ -33,31 +49,31 @@
*/
public class Trivial {
- static Category cat = Category.getInstance(Trivial.class.getName());
+ static Logger logger = Logger.getLogger(Trivial.class);
public static void main(String[] args) {
BasicConfigurator.configure();
NDC.push("Client #45890");
- cat.info("Awake awake. Put on thy strength.");
+ logger.info("Awake awake. Put on thy strength.");
Trivial.foo();
InnerTrivial.foo();
- cat.info("Exiting Trivial.");
+ logger.info("Exiting Trivial.");
}
static
void foo() {
NDC.push("DB");
- cat.debug("Now king David was old.");
+ logger.debug("Now king David was old.");
NDC.pop();
}
static class InnerTrivial {
- static Category cat = Category.getInstance(InnerTrivial.class.getName());
+ static Logger logger = Logger.getLogger(InnerTrivial.class);
static
void foo() {
- cat.info("Entered foo.");
+ logger.info("Entered foo.");
}
}
}
diff --git a/examples/customLevel/XLevel.java b/examples/customLevel/XLevel.java
index 2977aebe59..d4d1b902f3 100644
--- a/examples/customLevel/XLevel.java
+++ b/examples/customLevel/XLevel.java
@@ -1,8 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package examples.customLevel;
import org.apache.log4j.Level;
-import org.apache.log4j.Priority;
/**
@@ -11,6 +26,7 @@
*/
public class XLevel extends Level {
+ private static final long serialVersionUID = 2626753561969426769L;
static public final int TRACE_INT = Level.DEBUG_INT - 1;
static public final int LETHAL_INT = Level.FATAL_INT + 1;
diff --git a/examples/factor.html b/examples/factor.html
index bf9f27ffd0..af593c7425 100644
--- a/examples/factor.html
+++ b/examples/factor.html
@@ -1,4 +1,21 @@
+
+
+ Thanks to Dave Herman for providing detailed scenarios exposing
+ the issues involved. See
+ http://forum.java.sun.com/thread.jsp?forum=38&thread=70946
+ http://forum.java.sun.com/thread.jsp?forum=38&thread=70946#479697
+ http://marc.theaimsgroup.com/?l=ant-user&m=101139178705895&w=2
+ for more details.AsyncAppender can only
- be script configured using the {@link
- org.apache.log4j.xml.DOMConfigurator}. Refer to example configuration
- files sample4.xml
- and sample5.xml.
-
-
-
- @author Ceki Gülcü
- @since 0.9.1 */
-public class AsyncAppender extends AppenderSkeleton
- implements AppenderAttachable {
-
- /** The default buffer size is set to 128 events. */
- public static final int DEFAULT_BUFFER_SIZE = 128;
-
- //static Category cat = Category.getInstance(AsyncAppender.class.getName());
-
- BoundedFIFO bf = new BoundedFIFO(DEFAULT_BUFFER_SIZE);
-
- AppenderAttachableImpl aai;
- Dispatcher dispatcher;
- boolean locationInfo = false;
-
- boolean interruptedWarningMessage = false;
-
- public
- AsyncAppender() {
- // Note: The dispatcher code assumes that the aai is set once and
- // for all.
- aai = new AppenderAttachableImpl();
- dispatcher = new Dispatcher(bf, this);
- dispatcher.start();
- }
-
-
- public
- void addAppender(Appender newAppender) {
- synchronized(aai) {
- aai.addAppender(newAppender);
- }
- }
-
- public
- void append(LoggingEvent event) {
- // Set the NDC and thread name for the calling thread as these
- // LoggingEvent fields were not set at event creation time.
- event.getNDC();
- event.getThreadName();
- // Get a copy of this thread's MDC.
- event.getMDCCopy();
- if(locationInfo) {
- event.getLocationInformation();
- }
- synchronized(bf) {
- while(bf.isFull()) {
- try {
- //LogLog.debug("Waiting for free space in buffer, "+bf.length());
- bf.wait();
- } catch(InterruptedException e) {
- if(!interruptedWarningMessage) {
- interruptedWarningMessage = true;
- LogLog.warn("AsyncAppender interrupted.", e);
- } else {
- LogLog.warn("AsyncAppender interrupted again.");
- }
- }
- }
-
- //cat.debug("About to put new event in buffer.");
- bf.put(event);
- if(bf.wasEmpty()) {
- //cat.debug("Notifying dispatcher to process events.");
- bf.notify();
- }
- }
- }
-
- /**
- Close this AsyncAppender by interrupting the
- dispatcher thread which will process all pending events before
- exiting.
- */
- public
- void close() {
- synchronized(this) {
- // avoid multiple close, otherwise one gets NullPointerException
- if(closed) {
- return;
- }
- closed = true;
- }
-
- // The following cannot be synchronized on "this" because the
- // dispatcher synchronizes with "this" in its while loop. If we
- // did synchronize we would systematically get deadlocks when
- // close was called.
- dispatcher.close();
- try {
- dispatcher.join();
- } catch(InterruptedException e) {
- LogLog.error("Got an InterruptedException while waiting for the "+
- "dispatcher to finish.", e);
- }
- dispatcher = null;
- bf = null;
- }
-
- public
- Enumeration getAllAppenders() {
- synchronized(aai) {
- return aai.getAllAppenders();
- }
- }
-
- public
- Appender getAppender(String name) {
- synchronized(aai) {
- return aai.getAppender(name);
- }
- }
-
- /**
- Returns the current value of the LocationInfo option.
- */
- public
- boolean getLocationInfo() {
- return locationInfo;
- }
-
- /**
- Is the appender passed as parameter attached to this category?
- */
- public
- boolean isAttached(Appender appender) {
- return aai.isAttached(appender);
- }
-
-
- /**
- The AsyncAppender does not require a layout. Hence,
- this method always returns false. */
- public
- boolean requiresLayout() {
- return false;
- }
-
- public
- void removeAllAppenders() {
- synchronized(aai) {
- aai.removeAllAppenders();
- }
- }
-
-
- public
- void removeAppender(Appender appender) {
- synchronized(aai) {
- aai.removeAppender(appender);
- }
- }
-
- public
- void removeAppender(String name) {
- synchronized(aai) {
- aai.removeAppender(name);
- }
- }
-
- /**
- The LocationInfo option takes a boolean value. By
- default, it is set to false which means there will be no effort
- to extract the location information related to the event. As a
- result, the event that will be ultimately logged will likely to
- contain the wrong location information (if present in the log
- format).
-
- System.out or
- System.err using a layout specified by the
- user. The default target is System.out.
-
- @author Ceki Gülcü
- @since 1.1 */
-public class ConsoleAppender extends WriterAppender {
-
- public static final String SYSTEM_OUT = "System.out";
- public static final String SYSTEM_ERR = "System.err";
-
- protected String target = SYSTEM_OUT;
-
- /**
- The default constructor does nothing.
- */
- public ConsoleAppender() {
- }
-
- public ConsoleAppender(Layout layout) {
- this(layout, SYSTEM_OUT);
- }
-
- public ConsoleAppender(Layout layout, String target) {
- this.layout = layout;
-
- if (SYSTEM_OUT.equals(target)) {
- setWriter(new OutputStreamWriter(System.out));
- } else if (SYSTEM_ERR.equalsIgnoreCase(target)) {
- setWriter(new OutputStreamWriter(System.err));
- } else {
- targetWarn(target);
- }
- }
-
- /**
- Sets the value of the Target option. Recognized values are
- "System.out" and "System.err". Any other value will be ignored.
- */
- public
- void setTarget(String value) {
- String v = value.trim();
-
- if (SYSTEM_OUT.equalsIgnoreCase(v)) {
- target = SYSTEM_OUT;
- } else if (SYSTEM_ERR.equalsIgnoreCase(v)) {
- target = SYSTEM_ERR;
- } else {
- targetWarn(value);
- }
- }
-
- /**
- Returns the current value of the Target property. The default
- value of the option is "System.out".
-
- See also {@link #setTarget}.
-
- */
- public
- String getTarget() {
- return target;
- }
-
- void targetWarn(String val) {
- LogLog.warn("["+val+"] should be System.out or System.err.");
- LogLog.warn("Using System.out (default).");
- }
-
- public
- void activateOptions() {
- if(target.equals(SYSTEM_OUT)) {
- setWriter(new OutputStreamWriter(System.out));
- } else {
- setWriter(new OutputStreamWriter(System.err));
- }
- }
-
- /**
- Override the parent method to do nothing.
- */
- protected
- final
- void closeWriter() {
- }
-}
diff --git a/src/java/org/apache/log4j/DefaultCategoryFactory.java b/src/java/org/apache/log4j/DefaultCategoryFactory.java
deleted file mode 100644
index 1250084d3e..0000000000
--- a/src/java/org/apache/log4j/DefaultCategoryFactory.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j;
-
-import org.apache.log4j.spi.LoggerFactory;
-
-class DefaultCategoryFactory implements LoggerFactory {
-
- DefaultCategoryFactory() {
- }
-
- public
- Logger makeNewLoggerInstance(String name) {
- return new Logger(name);
- }
-}
diff --git a/src/java/org/apache/log4j/Logger.java b/src/java/org/apache/log4j/Logger.java
deleted file mode 100644
index aab789ddad..0000000000
--- a/src/java/org/apache/log4j/Logger.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j;
-
-import org.apache.log4j.spi.LoggerFactory;
-
-
-/**
- This is the central class in the log4j package. Most logging
- operations, except configuration, are done through this class.
-
- @since log4j 1.2
-
- @author Ceki Gülcü */
-public class Logger extends Category {
-
- /**
- The fully qualified name of the Level class. See also the
- getFQCN method. */
- private static final String FQCN = Level.class.getName();
-
-
- protected
- Logger(String name) {
- super(name);
- }
-
- /**
- Log a message object with the {@link Level#FINE FINE} level which
- is just an alias for the {@link Level#DEBUG DEBUG} level.
-
- DEBUG
- enabled by comparing the level of this category with the {@link
- Level#DEBUG DEBUG} level. If this category is
- DEBUG enabled, then it converts the message object
- (passed as parameter) to a string by invoking the appropriate
- {@link org.apache.log4j.or.ObjectRenderer}. It then proceeds to call all the
- registered appenders in this category and also higher in the
- hierarchy depending on the value of the additivity flag.
-
- Throwable but no
- stack trace. To print a stack trace use the {@link #debug(Object,
- Throwable)} form instead.
-
- @param message the message object to log. */
- //public
- //void fine(Object message) {
- // if(repository.isDisabled(Level.DEBUG_INT))
- // return;
- // if(Level.DEBUG.isGreaterOrEqual(this.getChainedLevel())) {
- // forcedLog(FQCN, Level.DEBUG, message, null);
- // }
- //}
-
-
- /**
- Log a message object with the FINE level including
- the stack trace of the {@link Throwable} t passed as
- parameter.
-
- getLogger(clazz.getName()).
- */
- static
- public
- Logger getLogger(Class clazz) {
- return LogManager.getLogger(clazz.getName());
- }
-
-
- /**
- Retrieve the root logger.
- */
- public
- static
- Logger getRootLogger() {
- return LogManager.getRootLogger();
- }
-
- /**
- Like {@link #getLogger(String)} except that the type of logger
- instantiated depends on the type returned by the {@link
- LoggerFactory#makeNewLoggerInstance} method of the
- factory parameter.
-
- resource in different
- places. The rearch order is as follows:
-
-
-
-
-
- */
- static
- public
- URL getResource(String resource) {
- ClassLoader classLoader = null;
- URL url = null;
-
- try {
- if(!java1) {
- classLoader = Thread.currentThread().getContextClassLoader();
- if(classLoader != null) {
- LogLog.debug("Trying to find ["+resource+"] using context classloader "
- +classLoader+".");
- url = classLoader.getResource(resource);
- if(url != null) {
- return url;
- }
- }
- }
-
- // We could not find resource. Ler us now try with the
- // classloader that loaded this class.
- classLoader = Loader.class.getClassLoader();
- if(classLoader == null) {
- LogLog.warn("Loader.class.getClassLoader returned null!");
- } else {
-
- LogLog.debug("Trying to find ["+resource+"] using "+classLoader
- +" class loader.");
- url = classLoader.getResource(resource);
- if(url != null) {
- return url;
- }
- }
- } catch(Throwable t) {
- LogLog.warn(TSTR, t);
- }
-
- // Last ditch attempt: get the resource from the class path. It
- // may be the case that clazz was loaded by the Extentsion class
- // loader which the parent of the system class loader. Hence the
- // code below.
- LogLog.debug("Trying to find ["+resource+
- "] using ClassLoader.getSystemResource().");
- return ClassLoader.getSystemResource(resource);
- }
-
- /**
- Are we running under JDK 1.x?
- */
- public
- static
- boolean isJava1() {
- return java1;
- }
-
-
- /**
- Load the specified class using the resource using the thread context
- class loader under Java2. If that fails, search for
- resource using the class loader that loaded this
- class (Loader). Under JDK 1.1, only the the class
- loader that loaded this class (Loader) is used.
-
- ClassLoader.getSystemResource(resource), that is is
- using the system class loader in JDK 1.2 and virtual machine's
- built-in class loader in JDK 1.1.
-
- Thread
- contextClassLoader if running under Java2 or current
- class loader if running under JDK 1.1.
- */
- static
- public
- Class loadClass (Double clazz) throws ClassNotFoundException {
- return null;
- // if(java1) {
- // return Class.forName(clazz);
- // } else {
- // try {
- // return Thread.currentThread().getContextClassLoader().loadClass(clazz);
- // } catch(Exception e) {
- // // we reached here because
- // // currentThread().getContextClassLoader() is null or because
- // // of a security exceptio, or because clazz could not be
- // // loaded, in any case we now try one more time
- // return Class.forName(clazz);
- // }
- // }
- }
-}
diff --git a/src/java/org/apache/log4j/helpers/NullEnumeration.java b/src/java/org/apache/log4j/helpers/NullEnumeration.java
deleted file mode 100644
index e7dd29e2ee..0000000000
--- a/src/java/org/apache/log4j/helpers/NullEnumeration.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-
-package org.apache.log4j.helpers;
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-/**
-
- An always-empty Enumerator.
-
- @author Anders Kristensen
- @since version 1.0
- */
-public class NullEnumeration implements Enumeration {
- private static final NullEnumeration instance = new NullEnumeration();
-
- private
- NullEnumeration() {
- }
-
- public
- static
- NullEnumeration getInstance() {
- return instance;
- }
-
- public
- boolean hasMoreElements() {
- return false;
- }
-
- public
- Object nextElement() {
- throw new NoSuchElementException();
- }
-}
diff --git a/src/java/org/apache/log4j/helpers/SyslogQuietWriter.java b/src/java/org/apache/log4j/helpers/SyslogQuietWriter.java
deleted file mode 100644
index 9e30777dc7..0000000000
--- a/src/java/org/apache/log4j/helpers/SyslogQuietWriter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-
-package org.apache.log4j.helpers;
-
-
-
-import java.io.Writer;
-import org.apache.log4j.spi.ErrorHandler;
-
-/**
- SyslogQuietWriter extends QuietWriter by prepending the syslog
- level code before each printed String.
-
- @since 0.7.3
-*/
-public class SyslogQuietWriter extends QuietWriter {
-
- int syslogFacility;
- int level;
-
- public
- SyslogQuietWriter(Writer writer, int syslogFacility, ErrorHandler eh) {
- super(writer, eh);
- this.syslogFacility = syslogFacility;
- }
-
- public
- void setLevel(int level) {
- this.level = level;
- }
-
- public
- void setSyslogFacility(int syslogFacility) {
- this.syslogFacility = syslogFacility;
- }
-
- public
- void write(String string) {
- super.write("<"+(syslogFacility | level)+">" + string);
- }
-}
diff --git a/src/java/org/apache/log4j/helpers/SyslogWriter.java b/src/java/org/apache/log4j/helpers/SyslogWriter.java
deleted file mode 100644
index 81a05f152a..0000000000
--- a/src/java/org/apache/log4j/helpers/SyslogWriter.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-
-package org.apache.log4j.helpers;
-
-
-import java.io.Writer;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.DatagramPacket;
-import java.net.UnknownHostException;
-import java.net.SocketException;
-import java.io.IOException;
-
-/**
- SyslogWriter is a wrapper around the java.net.DatagramSocket class
- so that it behaves like a java.io.Writer.
-
- @since 0.7.3
-*/
-public class SyslogWriter extends Writer {
-
- final int SYSLOG_PORT = 514;
- static String syslogHost;
-
- private InetAddress address;
- private DatagramSocket ds;
-
- public
- SyslogWriter(String syslogHost) {
- this.syslogHost = syslogHost;
-
- try {
- this.address = InetAddress.getByName(syslogHost);
- }
- catch (UnknownHostException e) {
- LogLog.error("Could not find " + syslogHost +
- ". All logging will FAIL.", e);
- }
-
- try {
- this.ds = new DatagramSocket();
- }
- catch (SocketException e) {
- e.printStackTrace();
- LogLog.error("Could not instantiate DatagramSocket to " + syslogHost +
- ". All logging will FAIL.", e);
- }
- }
-
-
- public
- void write(char[] buf, int off, int len) throws IOException {
- this.write(new String(buf, off, len));
- }
-
- public
- void write(String string) throws IOException {
- DatagramPacket packet = new DatagramPacket(string.getBytes(),
- string.length(),
- address, SYSLOG_PORT);
-
- if(this.ds != null)
- ds.send(packet);
-
- }
-
- public
- void flush() {}
-
- public
- void close() {}
-}
diff --git a/src/java/org/apache/log4j/helpers/ThreadLocalMap.java b/src/java/org/apache/log4j/helpers/ThreadLocalMap.java
deleted file mode 100644
index 811314ba34..0000000000
--- a/src/java/org/apache/log4j/helpers/ThreadLocalMap.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-
-package org.apache.log4j.helpers;
-
-import java.util.Hashtable;
-
-/**
- ThreadLocalMap extends {@link InheritableThreadLocal}
- to bequeath a copy of the hashtable of the MDC of the parent
- thread.
-
- @author Ceki Gülcü
- @since 1.2
-*/
-final public class ThreadLocalMap extends InheritableThreadLocal {
-
- public
- final
- Object childValue(Object parentValue) {
- Hashtable ht = (Hashtable) parentValue;
- if(ht != null) {
- return ht.clone();
- } else {
- return null;
- }
- }
-}
diff --git a/src/java/org/apache/log4j/helpers/Transform.java b/src/java/org/apache/log4j/helpers/Transform.java
deleted file mode 100644
index 66e6c8041b..0000000000
--- a/src/java/org/apache/log4j/helpers/Transform.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j.helpers;
-
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.LocationInfo;
-
-/**
- Utility class for transforming strings.
- */
-public class Transform {
-
- /**
- * This method takes a string which may contain HTML tags (ie, , ,
- * etc) and converts the '<' and '>' characters to their HTML escape
- * sequences.
- *
- * @param input The text to be converted.
- * @return The input string with the characters '<' and '>' replaced with
- * < and > respectively.
- */
- static
- public
- String escapeTags(String input) {
- //Check if the string is null or zero length -- if so, return
- //what was sent in.
-
- if( input == null || input.length() == 0 ) {
- return input;
- }
-
- //Use a StringBuffer in lieu of String concatenation -- it is
- //much more efficient this way.
-
- StringBuffer buf = new StringBuffer(input.length() + 6);
- char ch = ' ';
-
- int len = input.length();
- for(int i=0; i < len; i++) {
- ch = input.charAt(i);
- if(ch == '<') {
- buf.append("<");
- } else if(ch == '>') {
- buf.append(">");
- } else {
- buf.append(ch);
- }
- }
- return buf.toString();
- }
-}
diff --git a/src/java/org/apache/log4j/jmx/Agent.java b/src/java/org/apache/log4j/jmx/Agent.java
deleted file mode 100644
index 3049a91792..0000000000
--- a/src/java/org/apache/log4j/jmx/Agent.java
+++ /dev/null
@@ -1,39 +0,0 @@
-
-package org.apache.log4j.jmx;
-
-import javax.management.ObjectName;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import com.sun.jdmk.comm.HtmlAdaptorServer;
-
-import org.apache.log4j.Category;
-
-
-public class Agent {
-
- static Category log = Category.getInstance(Agent.class);
-
- public Agent() {
- }
-
-
- public
- void start() {
-
- MBeanServer server = MBeanServerFactory.createMBeanServer();
- HtmlAdaptorServer html = new HtmlAdaptorServer();
-
- try {
- log.info("Registering HtmlAdaptorServer instance.");
- server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
- log.info("Registering HierarchyDynamicMBean instance.");
- HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
- server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
-
- } catch(Exception e) {
- log.error("Problem while regitering MBeans instances.", e);
- return;
- }
- html.start();
- }
-}
diff --git a/src/java/org/apache/log4j/jmx/MethodUnion.java b/src/java/org/apache/log4j/jmx/MethodUnion.java
deleted file mode 100644
index f810d654f0..0000000000
--- a/src/java/org/apache/log4j/jmx/MethodUnion.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j.jmx;
-
-import java.lang.reflect.Method;
-
-class MethodUnion {
-
- Method readMethod;
- Method writeMethod;
-
- MethodUnion( Method readMethod, Method writeMethod) {
- this.readMethod = readMethod;
- this.writeMethod = writeMethod;
- }
-
-}
diff --git a/src/java/org/apache/log4j/jmx/T.java b/src/java/org/apache/log4j/jmx/T.java
deleted file mode 100644
index 24724744e3..0000000000
--- a/src/java/org/apache/log4j/jmx/T.java
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-import org.apache.log4j.jmx.Agent;
-import org.apache.log4j.Category;
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.*;
-
-public class T {
-
-
- public static void main(String[] args) {
- Category cat = Category.getInstance(T.class);
- Layout layout = new PatternLayout("%r %p [%t] %c - %m%n");
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
-
- consoleAppender.setName("console");
- BasicConfigurator.configure(consoleAppender);
- Agent agent = new Agent();
- agent.start();
- }
-
-}
diff --git a/src/java/org/apache/log4j/lf5/util/ProductProperties.java b/src/java/org/apache/log4j/lf5/util/ProductProperties.java
deleted file mode 100644
index dc9e41ba01..0000000000
--- a/src/java/org/apache/log4j/lf5/util/ProductProperties.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
- */
-package org.apache.log4j.lf5.util;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * ProductProperties holds the properties dealing with
- * this product. There is never a need
- * for multiple instances of this class, thus this class
- * is a singleton.
- *
- * The properties file format is as follows:
- *
- * #Any arbitrary comments are denoted with a #
- *
- * #Mandatory properties
- * product.name=
TopicConnectionFactory from the JNDI context.
- */
- public
- void setTopicConnectionFactoryBindingName(String tcfBindingName) {
- this.tcfBindingName = tcfBindingName;
- }
-
- /**
- Returns the value of the TopicConnectionFactoryBindingName option.
- */
- public
- String getTopicConnectionFactoryBindingName() {
- return tcfBindingName;
- }
-
- /**
- The TopicBindingName option takes a
- string value. Its value will be used to lookup the appropriate
- Topic from the JNDI context.
- */
- public
- void setTopicBindingName(String topicBindingName) {
- this.topicBindingName = topicBindingName;
- }
-
- /**
- Returns the value of the TopicBindingName option.
- */
- public
- String getTopicBindingName() {
- return topicBindingName;
- }
-
-
- /**
- Returns value of the LocationInfo property which
- determines whether location (stack) info is sent to the remote
- subscriber. */
- public
- boolean getLocationInfo() {
- return locationInfo;
- }
-
- public
- void activateOptions() {
- TopicConnectionFactory topicConnectionFactory;
-
- try {
- Context ctx = new InitialContext();
- topicConnectionFactory = (TopicConnectionFactory) lookup(ctx, tcfBindingName);
- topicConnection = topicConnectionFactory.createTopicConnection();
- topicConnection.start();
-
- topicSession = topicConnection.createTopicSession(false,
- Session.AUTO_ACKNOWLEDGE);
-
- Topic topic = (Topic) lookup(ctx, topicBindingName);
- topicPublisher = topicSession.createPublisher(topic);
-
- ctx.close();
- } catch(Exception e) {
- errorHandler.error("Error while activating options for appender named ["+name+
- "].", e, ErrorCode.GENERIC_FAILURE);
- }
- }
-
- protected
- Object lookup(Context ctx, String name) throws NamingException {
- try {
- return ctx.lookup(name);
- } catch(NameNotFoundException e) {
- LogLog.error("Could not find name ["+name+"].");
- throw e;
- }
- }
-
- protected
- boolean checkEntryConditions() {
- String fail = null;
-
- if(this.topicConnection == null) {
- fail = "No TopicConnection";
- } else if(this.topicSession == null) {
- fail = "No TopicSession";
- } else if(this.topicPublisher == null) {
- fail = "No TopicPublisher";
- }
-
- if(fail != null) {
- errorHandler.error(fail +" for JMSAppender named ["+name+"].");
- return false;
- } else {
- return true;
- }
- }
-
- /**
- Close this JMSAppender. Closing releases all resources used by the
- appender. A closed appender cannot be re-opened. */
- public
- synchronized // avoid concurrent append and close operations
- void close() {
- if(this.closed)
- return;
-
- LogLog.debug("Closing appender ["+name+"].");
- this.closed = true;
-
- try {
- if(topicSession != null)
- topicSession.close();
- if(topicConnection != null)
- topicConnection.close();
- } catch(Exception e) {
- LogLog.error("Error while closing JMSAppender ["+name+"].", e);
- }
- // Help garbage collection
- topicPublisher = null;
- topicSession = null;
- topicConnection = null;
- }
-
- /**
- This method called by {@link AppenderSkeleton#doAppend} method to
- do most of the real appending work. */
- public
- void append(LoggingEvent event) {
- if(!checkEntryConditions()) {
- return;
- }
-
- try {
- ObjectMessage msg = topicSession.createObjectMessage();
- if(locationInfo) {
- event.getLocationInformation();
- }
- msg.setObject(event);
- topicPublisher.publish(msg);
- } catch(Exception e) {
- errorHandler.error("Could not publish message in JMSAppender ["+name+"].", e,
- ErrorCode.GENERIC_FAILURE);
- }
- }
-
- /**
- If true, the information sent to the remote subscriber will include
- location information. By default no location information is sent
- to the subscriber. */
- public
- void setLocationInfo(boolean locationInfo) {
- this.locationInfo = locationInfo;
- }
-
-
- public
- boolean requiresLayout() {
- return false;
- }
-}
diff --git a/src/java/org/apache/log4j/net/JMSSink.java b/src/java/org/apache/log4j/net/JMSSink.java
deleted file mode 100644
index 877df006e4..0000000000
--- a/src/java/org/apache/log4j/net/JMSSink.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j.net;
-
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.Category;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.spi.RendererSupport;
-import org.apache.log4j.spi.LoggerRepository;
-import org.apache.log4j.or.jms.MessageRenderer;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.helpers.LogLog;
-
-import javax.jms.*;
-
-import javax.naming.InitialContext;
-import javax.naming.Context;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-/**
- A simple application receiving the logging events sent by a JMSAppender.
-
-
- @author Ceki Gülcü
-*/
-public class JMSSink {
-
- static public void main(String[] args) {
- if(args.length != 3) {
- usage("Wrong number of arguments.");
- }
-
- String tcfBindingName = args[0];
- String topicBindingName = args[1];
- PropertyConfigurator.configure(args[2]);
-
- LoggerRepository rep = LogManager.getLoggerRepository();
- if(rep instanceof RendererSupport) {
- ((RendererSupport) rep).setRenderer(Message.class, new MessageRenderer());
- }
-
- try {
- Context ctx = new InitialContext();
- TopicConnectionFactory topicConnectionFactory;
- topicConnectionFactory = (TopicConnectionFactory) lookup(ctx,
- tcfBindingName);
-
- TopicConnection topicConnection =
- topicConnectionFactory.createTopicConnection();
- topicConnection.start();
-
- TopicSession topicSession = topicConnection.createTopicSession(false,
- Session.AUTO_ACKNOWLEDGE);
-
- Topic topic = (Topic)ctx.lookup(topicBindingName);
-
- //TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic);
- TopicSubscriber topicSubscriber =
- topicSession.createDurableSubscriber(topic, "x");
-
-
- LoggingEvent event;
- Category remoteCategory;
-
- while(true) {
- ObjectMessage msg = (ObjectMessage)topicSubscriber.receive();
- event = (LoggingEvent) msg.getObject();
- remoteCategory = Category.getInstance(event.categoryName);
- remoteCategory.callAppenders(event);
-
- // dump the JMSMessage
- // remoteCategory.debug(msg);
-
- }
- } catch(Exception e) {
- LogLog.error("Could not read JMS message.", e);
- }
- }
-
-
- protected
- static
- Object lookup(Context ctx, String name) throws NamingException {
- try {
- return ctx.lookup(name);
- } catch(NameNotFoundException e) {
- LogLog.error("Could not find name ["+name+"].");
- throw e;
- }
- }
-
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println("Usage: java " + JMSSink.class.getName()
- + " TopicConnectionFactoryBindingName TopicBindingName configFile");
- System.exit(1);
- }
-}
diff --git a/src/java/org/apache/log4j/net/SimpleSocketServer.java b/src/java/org/apache/log4j/net/SimpleSocketServer.java
deleted file mode 100644
index f8ca382ffb..0000000000
--- a/src/java/org/apache/log4j/net/SimpleSocketServer.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-package org.apache.log4j.net;
-
-import java.net.Socket;
-import java.net.ServerSocket;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.PropertyConfigurator;
-
-
-/**
- A simple {@link SocketNode} based server.
-
-
- Usage: java org.apache.log4j.net.SimpleSocketServer port configFile
-
- where port is a part number where the server listens and
- configFile is a configuration file fed to the {@link
- PropertyConfigurator}.
-
-
- @author Ceki Gülcü
-
- @since 0.8.4 */
-
-public class SimpleSocketServer {
-
- static Category cat = Category.getInstance(SimpleSocketServer.class.getName());
-
- static int port;
-
- public
- static
- void main(String argv[]) {
- if(argv.length == 2)
- init(argv[0], argv[1]);
- else
- usage("Wrong number of arguments.");
-
- try {
- cat.info("Listening on port " + port);
- ServerSocket serverSocket = new ServerSocket(port);
- while(true) {
- cat.info("Waiting to accept a new client.");
- Socket socket = serverSocket.accept();
- cat.info("Connected to client at " + socket.getInetAddress());
- cat.info("Starting new socket node.");
- new Thread(new SocketNode(socket,
- LogManager.getLoggerRepository())).start();
- }
- }
- catch(Exception e) {
- e.printStackTrace();
- }
- }
-
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println(
- "Usage: java " +SimpleSocketServer.class.getName() + " port configFile");
- System.exit(1);
- }
-
- static
- void init(String portStr, String configFile) {
- try {
- port = Integer.parseInt(portStr);
- }
- catch(java.lang.NumberFormatException e) {
- e.printStackTrace();
- usage("Could not interpret port number ["+ portStr +"].");
- }
- PropertyConfigurator.configure(configFile);
- }
-}
diff --git a/src/java/org/apache/log4j/net/SocketNode.java b/src/java/org/apache/log4j/net/SocketNode.java
deleted file mode 100644
index 4bcbd8235d..0000000000
--- a/src/java/org/apache/log4j/net/SocketNode.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-
-package org.apache.log4j.net;
-
-import java.net.Socket;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.BufferedInputStream;
-
-
-import org.apache.log4j.*;
-import org.apache.log4j.spi.*;
-
-// Contributors: Moses Hohman toString method.
-
- @author Ceki Gülcü
- @since 1.0 */
-class DefaultRenderer implements ObjectRenderer {
-
- DefaultRenderer() {
- }
-
- /**
- Render the object passed as parameter by calling its
- toString method. */
- public
- String doRender(Object o) {
- return o.toString();
- }
-}
diff --git a/src/java/org/apache/log4j/or/ObjectRenderer.java b/src/java/org/apache/log4j/or/ObjectRenderer.java
deleted file mode 100644
index 5d98d69ce4..0000000000
--- a/src/java/org/apache/log4j/or/ObjectRenderer.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-package org.apache.log4j.or;
-
-/**
- Implement this interface in order to render objects as strings.
-
- @author Ceki Gülcü
- @since 1.0 */
-public interface ObjectRenderer {
-
- /**
- Render the object passed as parameter as a String.
- */
- public
- String doRender(Object o);
-}
diff --git a/src/java/org/apache/log4j/performance/ConcatVsArray.java b/src/java/org/apache/log4j/performance/ConcatVsArray.java
deleted file mode 100644
index a3f6aca97f..0000000000
--- a/src/java/org/apache/log4j/performance/ConcatVsArray.java
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 1996-1999, International Business Machines
-// Corporation. All Rights Reserved.
-
-package org.apache.log4j.performance;
-
-import java.util.Date;
-
-/**
- Measure difference in performance of string concatenation versus
- creating an anonymous string array.
-
-
-
-
-
-
- Layout
- NullAppender
- FileAppender
- FileAppender (no flush)
- AsyncAppender (no flush)
-
-
- SimpleLayout
- 4
- 21
- 16
- 33
-
-
- PatternLayout "%p - %m%n"
- 4
- 21
- 16
- 32
-
-
- PatternLayout "%-5p - %m%n"
- 4
- NA
- NA
- NA
-
-
- TTCCLayout/RELATIVE
- 10
- 37
- 31
- 45
-
-
- PatternLayout "%r [%t] %-5p %c{2} %x - %m%n"
- 11
- NA
- NA
- NA
-
-
- PatternLayout "%r [%t] %-5p %.10c %x - %m%n"
- 11
- NA
- NA
- NA
-
-
- PatternLayout "%r [%t] %-5p %.20c %x - %m%n"
- 11
- NA
- NA
- NA
-
-
- PatternLayout "%r [%t] %-5p %c - %m%n"
- 9
- 36
- 29
- 45
-
-
- TTCCLayout/ISO8601
- 25
- 58
- 51
- 71
-
-
- PatternLayout "%d{ISO8601} [%t] %-5p %c %x - %m%n"
- 28
- 62
- 55
- 76
-
-
- PatternLayout "%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n"
- 46
- 82
- 72
- 94
-
-
- PatternLayout "%l - %m%n"
- 241
- 317
- 299
- 251
-
-
- PatternLayout "%C.%M.%L - %m%n"
- 267
- NA
- NA
- NA
-
-
-
-
-
- @author Ceki Gülcü
-
- */
-public class Logging {
-
- static int runLength;
- static int delay = -1;
- /**
- A delay is applied after every AsyncAppender does not automatically
- increase performance. On the contrary, it significantly degrades
- performance. The performance tests done here very quickly fill up
- the bounded buffer of the AsyncAppender and there is
- cosiderable overhead in managing this bounded buffer.
-
- AsyncAppender would have tremendously reduced the cost
- of logging in terms of overall application runtime.
-
- AsyncLogger
- takes no time at all. In other words, logging is done for "free".
-
- burstLen log
- requests. The default value of this constant is 100. */
- static int burstLen = 100;
- static int DELAY_MULT = 1000/burstLen;
-
- static Category cat = Category.getInstance("A0123456789.B0123456789.C0123456789");
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println(
- "Usage: java "+Logging.class.getName()+" confFile runLength [delay] [burstLen]\n"+
- " confFile is an XML configuration file and\n"+
- " runLength (integer) is the length of test loop.\n"+
- " delay is the time in millisecs to wait every bustLen log requests.");
- System.exit(1);
- }
-
- /**
- Usage: java org.apache.log4j.performance.Logging confFile runLength [delay] [burstLen]
-
- confFile is an XML configuration file and
- runLength (integer) is the length of test loop,
- delay is the time in millisecs to sleep every
- bustLen log requests.
-
-
-
-
-
- @author Ceki Gülcü
-
-*/
-public class NotLogging {
-
- static int runLength;
-
- final static int INITIAL_HASH_SIZE = 101;
-
- static String SHORT_MSG = "Hello World";
-
- static Category SHORT_CAT = Category.getInstance("A0123456789");
- static Category MEDIUM_CAT= Category.getInstance("A0123456789.B0123456789");
- static Category LONG_CAT =
- Category.getInstance("A0123456789.B0123456789.C0123456789");
-
- static Category INEXISTENT_SHORT_CAT = Category.getInstance("I0123456789");
- static Category INEXISTENT_MEDIUM_CAT=
- Category.getInstance("I0123456789.B0123456789");
- static Category INEXISTENT_LONG_CAT=
- Category.getInstance("I0123456789.B0123456789.C0123456789");
-
-
- static Category[] CAT_ARRAY = new Category[] {SHORT_CAT, MEDIUM_CAT,
- LONG_CAT, INEXISTENT_SHORT_CAT,
- INEXISTENT_MEDIUM_CAT,
- INEXISTENT_LONG_CAT};
-
- static
- void Usage() {
- System.err.println(
- "Usage: java org.apache.log4j.test.NotLogging true|false runLength\n" +
- "true indicates shipped code, false indicates code in development" +
- " where runLength is an int representing the run length of loops\n"+
- "We suggest that runLength be at least 100'000.");
- System.exit(1);
- }
-
- public static void main(String argv[]) {
-
- if(argv.length != 2) {
- Usage();
- }
- ProgramInit(argv);
- double delta;
-
-
- System.out.println();
- for(int i = 0; i < CAT_ARRAY.length; i++) {
- delta = SimpleMessage(CAT_ARRAY[i], SHORT_MSG, runLength);
- System.out.println("Simple argument, " + delta
- + " micros. Cat: " + CAT_ARRAY[i].getName());
- }
-
- System.out.println();
- for(int i = 0; i < CAT_ARRAY.length; i++) {
- delta = FullyOptimizedComplexMessage(CAT_ARRAY[i], runLength);
- System.out.println("Fully optimized complex, " + delta +
- " micros. Cat: " + CAT_ARRAY[i].getName());
- }
-
- System.out.println();
- for(int i = 0; i < CAT_ARRAY.length; i++) {
- delta = ComplexMessage(CAT_ARRAY[i], runLength);
- System.out.println("Complex message argument, " + delta +
- " micros. Cat: " + CAT_ARRAY[i].getName());
- }
-
- }
-
- /**
- Program wide initialization method. */
- static
- void ProgramInit(String[] args) {
-
- try {
- runLength = Integer.parseInt(args[1]);
- }
- catch(java.lang.NumberFormatException e) {
- System.err.println(e);
- Usage();
- }
-
-
- ConsoleAppender appender = new ConsoleAppender(new SimpleLayout());
-
- if("false".equals(args[0])) {
- // nothing to do
- } else if ("true".equals(args[0])) {
- System.out.println("Flagging as shipped code.");
- Category.getDefaultHierarchy().setThreshold((Level) Level.WARN);
- } else
- Usage();
-
- SHORT_CAT.setLevel((Level) Level.INFO);
- Category.getRoot().setLevel((Level) Level.INFO);
-
- }
-
-
- static
- double SimpleMessage(Category category, String msg, long runLength) {
- long before = System.currentTimeMillis();
- for(int i = 0; i < runLength; i++) {
- category.debug(msg);
- }
- return (System.currentTimeMillis() - before)*1000.0/runLength;
- }
-
- static
- double FullyOptimizedComplexMessage(Category category, long runLength) {
- long before = System.currentTimeMillis();
- for(int i = 0; i < runLength; i++) {
- if(category.isDebugEnabled())
- category.debug("Message" + i +
- " bottles of beer standing on the wall.");
- }
- return (System.currentTimeMillis() - before)*1000.0/runLength;
- }
-
- static
- double ComplexMessage(Category category, long runLength) {
- long before = System.currentTimeMillis();
- for(int i = 0; i < runLength; i++) {
- category.debug("Message" + i +
- " bottles of beer standing on the wall.");
- }
- return (System.currentTimeMillis() - before)*1000.0/runLength;
- }
-}
diff --git a/src/java/org/apache/log4j/performance/NullAppender.java b/src/java/org/apache/log4j/performance/NullAppender.java
deleted file mode 100644
index e7ce56eb77..0000000000
--- a/src/java/org/apache/log4j/performance/NullAppender.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-package org.apache.log4j.performance;
-
-import org.apache.log4j.Layout;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.AppenderSkeleton;
-
-/**
- A bogus appender which calls the format method of its layout object
- but does not write the result anywhere.
- */
-public class NullAppender extends AppenderSkeleton {
-
- public static String s;
- public String t;
-
- public
- NullAppender() {}
-
- public
- NullAppender(Layout layout) {
- this.layout = layout;
- }
-
- public
- void close() {}
-
- public
- void doAppend(LoggingEvent event) {
- if(layout != null) {
- t = layout.format(event);
- s = t;
- }
- }
-
- public
- void append(LoggingEvent event) {
- }
-
- /**
- This is a bogus appender but it still uses a layout.
- */
- public
- boolean requiresLayout() {
- return true;
- }
-}
diff --git a/src/java/org/apache/log4j/performance/package.html b/src/java/org/apache/log4j/performance/package.html
deleted file mode 100644
index 91f326a97c..0000000000
--- a/src/java/org/apache/log4j/performance/package.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-Last modified: Thu Dec 16 10:32:43 MET 1999
-
-
diff --git a/src/java/org/apache/log4j/performance/xml/logging201.xml b/src/java/org/apache/log4j/performance/xml/logging201.xml
deleted file mode 100644
index d1c21e2d06..0000000000
--- a/src/java/org/apache/log4j/performance/xml/logging201.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-ENABLE_KEY is the name of the constant
- holding the string value log4j.enable.
-
- hierarchy
- parameter.
-
- @param url The URL to parse
- @param hierarchy The hierarchy to operation upon.
- */
- void doConfigure(URL url, LoggerRepository repository);
-}
diff --git a/src/java/org/apache/log4j/spi/DefaultRepositorySelector.java b/src/java/org/apache/log4j/spi/DefaultRepositorySelector.java
deleted file mode 100644
index d3550148e5..0000000000
--- a/src/java/org/apache/log4j/spi/DefaultRepositorySelector.java
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-package org.apache.log4j.spi;
-
-
-public class DefaultRepositorySelector implements RepositorySelector {
-
- final LoggerRepository repository;
-
- public
- DefaultRepositorySelector(LoggerRepository repository) {
- this.repository = repository;
- }
-
- public
- LoggerRepository getLoggerRepository() {
- return repository;
- }
-}
-
diff --git a/src/java/org/apache/log4j/spi/ErrorCode.java b/src/java/org/apache/log4j/spi/ErrorCode.java
deleted file mode 100644
index d56cdf99c1..0000000000
--- a/src/java/org/apache/log4j/spi/ErrorCode.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j.spi;
-
-
-/**
- This interface defines commonly encoutered error codes.
-
- @author Ceki Gülcü
- @since 0.9.0
- */
-public interface ErrorCode {
-
- public final int GENERIC_FAILURE = 0;
- public final int WRITE_FAILURE = 1;
- public final int FLUSH_FAILURE = 2;
- public final int CLOSE_FAILURE = 3;
- public final int FILE_OPEN_FAILURE = 4;
- public final int MISSING_LAYOUT = 5;
- public final int ADDRESS_PARSE_FAILURE = 6;
-}
diff --git a/src/java/org/apache/log4j/spi/HierarchyEventListener.java b/src/java/org/apache/log4j/spi/HierarchyEventListener.java
deleted file mode 100644
index 2837d1e1f0..0000000000
--- a/src/java/org/apache/log4j/spi/HierarchyEventListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j.spi;
-
-import org.apache.log4j.*;
-
-/**
- Listen to events occuring within a {@link
- org.apache.log4j.Hierarchy Hierarchy}.
-
- @author Ceki Gülcü
- @since 1.2
-
- */
-public interface HierarchyEventListener {
-
-
- //public
- //void categoryCreationEvent(Category cat);
-
-
- public
- void addAppenderEvent(Category cat, Appender appender);
-
- public
- void removeAppenderEvent(Category cat, Appender appender);
-
-
-}
diff --git a/src/java/org/apache/log4j/spi/LoggerFactory.java b/src/java/org/apache/log4j/spi/LoggerFactory.java
deleted file mode 100644
index 423deafc73..0000000000
--- a/src/java/org/apache/log4j/spi/LoggerFactory.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j.spi;
-
-import org.apache.log4j.Logger;
-
-/**
-
- Implement this interface to create new instances of Logger or
- a sub-class of Logger.
-
- examples/subclass/MyLogger.java for an example.
-
- @author Ceki Gülcü
- @since version 0.8.5
-
- */
-public interface LoggerFactory {
-
- public
- Logger makeNewLoggerInstance(String name);
-
-}
diff --git a/src/java/org/apache/log4j/spi/RendererSupport.java b/src/java/org/apache/log4j/spi/RendererSupport.java
deleted file mode 100644
index 6aef97300d..0000000000
--- a/src/java/org/apache/log4j/spi/RendererSupport.java
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-package org.apache.log4j.spi;
-
-import org.apache.log4j.*;
-import org.apache.log4j.or.RendererMap;
-import org.apache.log4j.or.ObjectRenderer;
-
-
-public interface RendererSupport {
-
- public
- RendererMap getRendererMap();
-
- public
- void setRenderer(Class renderedClass, ObjectRenderer renderer);
-
-}
diff --git a/src/java/org/apache/log4j/spi/ThrowableInformation.java b/src/java/org/apache/log4j/spi/ThrowableInformation.java
deleted file mode 100644
index 06d13c18e6..0000000000
--- a/src/java/org/apache/log4j/spi/ThrowableInformation.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j.spi;
-
-import java.io.Writer;
-import java.io.PrintWriter;
-import java.util.Vector;
-
-/**
-
-
-
- */
-public class ThrowableInformation implements java.io.Serializable {
-
- static final long serialVersionUID = -4748765566864322735L;
-
- private transient Throwable throwable;
- private String[] rep;
-
- public
- ThrowableInformation(Throwable throwable) {
- this.throwable = throwable;
- }
-
- public
- Throwable getThrowable() {
- return throwable;
- }
-
- public
- String[] getThrowableStrRep() {
- if(rep != null) {
- return (String[]) rep.clone();
- } else {
- VectorWriter vw = new VectorWriter();
- throwable.printStackTrace(vw);
- rep = vw.toStringArray();
- vw.clear();
- return rep;
- }
- }
-}
-
-class VectorWriter extends PrintWriter {
-
- private Vector v;
-
- VectorWriter() {
- super(new NullWriter());
- v = new Vector();
- }
-
- // Support for Orion
- public
- void print(Object o) {
- v.addElement(o.toString());
- }
-
- // Support for Orion
- public
- void print(char[] s) {
- v.addElement(new String(s));
- }
-
- // Support for Orion
- public
- void print(String s) {
- v.addElement(s);
- }
-
- public
- void println(Object o) {
- v.addElement(o.toString());
- }
-
- // JDK 1.1.x apprenly uses this form of println while in
- // printStackTrace()
- public
- void println(char[] s) {
- v.addElement(new String(s));
- }
-
- public
- void println(String s) {
- v.addElement(s);
- }
-
- public
- String[] toStringArray() {
- int len = v.size();
- String[] sa = new String[len];
- for(int i = 0; i < len; i++) {
- sa[i] = (String) v.elementAt(i);
- }
- return sa;
- }
-
- public
- void clear() {
- v.setSize(0);
- }
-}
-
-class NullWriter extends Writer {
-
- public
- void close() {
- }
-
- public
- void flush() {
- }
-
- public
- void write(char[] cbuf, int off, int len) {
- }
-}
-
diff --git a/src/java/org/apache/log4j/spi/TriggeringEventEvaluator.java b/src/java/org/apache/log4j/spi/TriggeringEventEvaluator.java
deleted file mode 100644
index c6872fdb70..0000000000
--- a/src/java/org/apache/log4j/spi/TriggeringEventEvaluator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-package org.apache.log4j.spi;
-
-/**
-
- Implementions of this interface allow certain appenders to decide
- when to perform an appender specific action.
-
- true and adds the event to an internal buffer when the
- returned result is false.
-
- @author Ceki Gülcü
- @since version 1.0
-
- */
-public interface TriggeringEventEvaluator {
-
- /**
- Is this the triggering event?
- */
- public boolean isTriggeringEvent(LoggingEvent event);
-}
diff --git a/src/java/org/apache/log4j/test/.cvsignore b/src/java/org/apache/log4j/test/.cvsignore
deleted file mode 100644
index 31b2fd0f00..0000000000
--- a/src/java/org/apache/log4j/test/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-test*
-current.reg*
-logging.lcf
-socket.lcf
-temp*
\ No newline at end of file
diff --git a/src/java/org/apache/log4j/test/.functions b/src/java/org/apache/log4j/test/.functions
deleted file mode 100644
index 38fec0f4de..0000000000
--- a/src/java/org/apache/log4j/test/.functions
+++ /dev/null
@@ -1,96 +0,0 @@
-
-# Constants
-NOPWriter=NOPWriter
-LCF=logging.lcf
-TEMP=temp
-OUTPUT=current.reg
-ROOT_PREFIX="log4j.rootCategory"
-CAT_PREFIX="log4j.category"
-
-DEF_DEBUG=-Dlog4j.configDebug
-
-SHALLOW_CAT="$CAT_PREFIX.org.apache.log4j.test.Shallow"
-LOG_CAT="$CAT_PREFIX.org.apache.log4j.Log"
-SIMPLE="org.apache.log4j.SimpleLayout"
-TTCC="org.apache.log4j.TTCCLayout"
-
-# +=============================================+
-# Strip the filename, retain the directory only.|
-# +=============================================+
-function getShellScriptDirectory {
- local dir
-
- dir=${0%/*}
-
- if [ "$dir" = "." ]
- then
- dir=$(pwd)
- elif [ "${dir#/}" = "$dir" ] # dir does not start with a /
- then
- dir=$(pwd)/$dir
- fi
- echo $dir
-}
-# +=============================================
-# Compensate for ZRL idiosyncrasy
-# +=============================================
-function setPERL {
- if [ -z "$PERL" ]
- then
- PERL=perl
- fi
-}
-# =============================================
-# Echo to $LCF
-# =============================================
-function lecho {
- # The quotes ensure that spaces in arguments are preserved.
- echo "$*" >> $LCF
-}
-# +============================================
-# Print a message and exit.
-# +============================================
-function die {
- echo $1
- exit 1
-}
-function makeRollingConfigFile {
- fileName=$1
- rootPriority=$2
- maxFileSize=$3;
- maxBackupIndex=$4;
-
- PRE="log4j.appender.roll"
- echo "$PRE=org.apache.log4j.RollingFileAppender" > $LCF
- echo "$PRE.File=$fileName" >> $LCF
- echo "$PRE.MaxFileSize=$maxFileSize" >> $LCF
- echo "$PRE.MaxBackupIndex=$maxBackupIndex" >> $LCF
-
- echo "$ROOT_PREFIX=$rootPriority, roll" >> $LCF
-
-}
-# ==============================================
-# Delete the file if exists
-# ==============================================
-function deleteFile {
- if [ -e $1 ]; then
- echo "Deleting file [$1]."
- rm $1
- fi
-}
-# ==============================================
-function runRollingFiles() {
- confFile=$1
-
- java -Dlog4j.configDebug=x org.apache.log4j.test.RollingFiles $confFile
-}
-# ----------------------------------------------------------------------
-function check() {
- if ! cmp -s $1 $2
- then
- echo "The output of current code DIFFERS from witness."
- exit 1;
- fi
-}
-# ----------------------------------------------------------------------
-
diff --git a/src/java/org/apache/log4j/test/AsyncAppenderTest.java b/src/java/org/apache/log4j/test/AsyncAppenderTest.java
deleted file mode 100644
index b3eff7faa4..0000000000
--- a/src/java/org/apache/log4j/test/AsyncAppenderTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.APL file.
- */
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.xml.DOMConfigurator;
-
-/**
- Test the coordination of the AsyncAppender with its Dispatcher.
- @author Ceki Gülcü
-*/
-public class AsyncAppenderTest {
-
- static Category cat = Category.getInstance(AsyncAppenderTest.class);
- static int delayBeforeClose;
-
-
- public
- static
- void main(String argv[]) {
-
- if(argv.length == 2)
- init(argv[0], argv[1]);
- else
- usage("Wrong number of arguments.");
- test();
- }
-
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java "+ Shallow.class.getName() +
- "configFile");
- System.exit(1);
- }
-
- static
- void init(String configFile, String delayBeforeCloseStr) {
- DOMConfigurator.configure(configFile);
- try {
- delayBeforeClose = Integer.parseInt(delayBeforeCloseStr);
- } catch(java.lang.NumberFormatException e) {
- e.printStackTrace();
- usage("Could not convert ["+delayBeforeCloseStr+"] to Integer.");
- }
- }
-
-
- static
- void test() {
- Category root = Category.getRoot();
- for(int i = 0; i < 100; i++) {
- root.debug("Message " + i);
- }
-
- try{Thread.currentThread().sleep(delayBeforeClose);}catch(Exception e){}
- Category.shutdown();
- }
-
-
-}
diff --git a/src/java/org/apache/log4j/test/Base64.java b/src/java/org/apache/log4j/test/Base64.java
deleted file mode 100644
index a3b1fc2c94..0000000000
--- a/src/java/org/apache/log4j/test/Base64.java
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 1996-1999, International Business Machines
-// Corporation. All Rights Reserved.
-
-
-package org.apache.log4j.test;
-
-class Base64 {
-
- final static int MAX_LINE = 76;
-
- static byte[] asciiEncoding =
- //A B C D E F G H I J K L M N O P Q
- {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
- //R S ... Z a b c d e f g
- 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103,
- //h i j k l m n o p q r s t u
- 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
- //v w x y z 0 1 2 3 4 5 6 7 8 9 + /
- 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47};
-
- static char[] charEnc = new char[64];
-
- static {
- for(int i = 0; i < 26; i ++) {
- charEnc[i] = (char) ('A' + i);
- charEnc[i+26] = (char) ('a' + i);
- }
- for(int i = 0; i < 10; i ++) {
- charEnc[i+52] = (char) ('0' + i);
- }
- charEnc[62] = '+';
- charEnc[63] = '/';
- }
-
-
-
- static
- String toString(byte[] inbuf) {
- return toString(inbuf, 0, inbuf.length);
- }
- /**
-
- */
- static
- String toString(byte[] inbuf, int offset, int length) {
-
- StringBuffer output = new StringBuffer((length)*4/3 + 1);
-
- int in;
- char[] out = new char[4];
-
- int i = offset;
- boolean ended = false;
- int last = offset + length;
- int j;
- int bitsRead;
-
- while(!ended) {
- in = 0;
- bitsRead = 0;
- for(j = 0; j < 3; j++) {
- if(i == last) {
- ended = true;
- break;
- }
- in = (in << 8) | (inbuf[i++] & 0xFF);
- bitsRead += 8;
- }
-
- while(bitsRead >= 6) {
- bitsRead -= 6;
- output.append(charEnc[(in >>> bitsRead) & 0x3F]);
- }
-
- if(bitsRead == 4) {
- output.append(charEnc[(in & 0x0F) << 2]);
- output.append("=");
- }
- else if (bitsRead == 2) {
- output.append(charEnc[(in & 0x03) << 4]);
- output.append("==");
- }
- }
- return output.toString();
- }
-
-
- public static void main(String[] args) {
-
- byte[] inbuf = new byte[MAX_LINE];
-
- while(true) {
- try {
- int read = System.in.read(inbuf, 0, MAX_LINE);
- if(read == -1) break;
- System.out.println("Read " + read + " chars.");
- System.out.println(Base64.toString(inbuf, 0, read));
- }
- catch (Exception e) {
- System.out.println("Exception " + e);
- }
-
- }
- }
-}
diff --git a/src/java/org/apache/log4j/test/CategoryWrapper.java b/src/java/org/apache/log4j/test/CategoryWrapper.java
deleted file mode 100644
index fd5928d679..0000000000
--- a/src/java/org/apache/log4j/test/CategoryWrapper.java
+++ /dev/null
@@ -1,61 +0,0 @@
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.*;
-
-/**
- This is just to test that wrapper can work. This implementation is
- actually quite bad and should be avoided.
-
-*/
-
-public class CategoryWrapper {
-
-
- Category c;
- static String FQCN = CategoryWrapper.class.getName();
-
- CategoryWrapper(String name) {
- c = Category.getInstance(name);
- }
-
- public
- static
- void main(String argv[]) {
- Layout layout = new PatternLayout("%p [%t] %C %F - %m\n");
- Appender out = new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT);
- CategoryWrapper w1 = new CategoryWrapper("c1");
- w1.addAppender(out);
- w1.print("hello");
- }
-
-
- public
- void addAppender(Appender appender) {
- c.addAppender(appender);
- }
-
- public
- void print(String msg) {
-
- // You have to supply the fully qualified named of the wrapper
- // class to the specially tailored category.log method for
- // PatternLayout's %C conversion pattern to work.
-
- // We have to add the ".print" string because the invocation of
- // wrapper.print method is made from the wrapper itself (main
- // method). This is highly unusual. The fqcn of the wrapper is
- // normally sufficient.
-
- c.log(FQCN+".print", Priority.DEBUG, msg, null);
- }
-
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println("Usage: java "+CategoryWrapper.class.getName()
- + " fileName");
- System.exit(1);
- }
-}
diff --git a/src/java/org/apache/log4j/test/ConfigurationFileParsing.java b/src/java/org/apache/log4j/test/ConfigurationFileParsing.java
deleted file mode 100644
index 0e274df7fc..0000000000
--- a/src/java/org/apache/log4j/test/ConfigurationFileParsing.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.Category;
-import org.apache.log4j.NDC;
-
-public class ConfigurationFileParsing {
-
- public
- static
- void main(String argv[]) {
-
- if(argv.length == 1) {
- NDC.push("testing");
- PropertyConfigurator.configure(argv[0]);
- Category root = Category.getRoot();
- root.debug("Message 1");
- root.debug("Message 2");
- NDC.pop();
- Category.shutdown();
- }
- else {
- Usage("Wrong number of arguments.");
- }
-
- }
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println("Usage: java "+ConfigurationFileParsing.class.getName()
- + " fileName");
- System.exit(1);
- }
-
-
-}
diff --git a/src/java/org/apache/log4j/test/DRFATest.java b/src/java/org/apache/log4j/test/DRFATest.java
deleted file mode 100644
index 07b0968e17..0000000000
--- a/src/java/org/apache/log4j/test/DRFATest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-
-package org.apache.log4j.test;
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.Category;
-import org.apache.log4j.Layout;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.Appender;
-import org.apache.log4j.DailyRollingFileAppender;
-
-
-/**
- This class is used in testing the DailyRollingFileAppender.
- @author Ceki Gülcü
-*/
-public class DRFATest {
-
- static Category cat = Category.getInstance(DRFATest.class);
-
- static int limit;
-
- public
- static
- void main(String argv[]) {
- if(argv.length == 1)
- init(argv[0]);
- else
- usage("Wrong number of arguments.");
- test();
- }
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java "+ DRFATest.class.getName()+" length");
- System.exit(1);
- }
-
- static
- void init(String limitStr) {
- try {
- limit = Integer.parseInt(limitStr);
- } catch(java.lang.NumberFormatException e) {
- usage("Could not convert "+limitStr+" to int");
- }
- }
-
- static
- void test() {
-
- Layout layout = new PatternLayout("%d{yyyy-MM-dd-HH-mm ss:SSS} %m%n");
- try {
- Appender appender = new DailyRollingFileAppender(layout, "test",
- "'.'yyyy-MM-dd-HH-mm" );
- appender.setName("drfa");
- BasicConfigurator.configure(appender);
- } catch(Exception e) {
- System.err.println("Could not create DailyRollingFileAppender");
- e.printStackTrace();
- }
-
- System.out.println("Limit: "+limit);
-
- for(int i = 0; i < limit; i++) {
- System.out.println(i);
- cat.debug("Message"+ i);
- delay(10000);
-
- if((i % 7) == 0) {
- System.out.println("Sleeping 1min.");
- delay(60000);
- System.err.println("");
- }
- }
- }
-
-
- static
- void delay(int amount) {
- try {
- Thread.currentThread().sleep(amount);
- }
- catch(Exception e) {}
- }
-}
-
diff --git a/src/java/org/apache/log4j/test/DefaultInit.java b/src/java/org/apache/log4j/test/DefaultInit.java
deleted file mode 100644
index 8c3616d996..0000000000
--- a/src/java/org/apache/log4j/test/DefaultInit.java
+++ /dev/null
@@ -1,21 +0,0 @@
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.Category;
-
-public class DefaultInit {
-
- static Category cat = Category.getInstance(DefaultInit.class);
-
- public static void main( String[] argv) {
- cat.debug("Hello world");
- }
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java org.apache.log4j.test.DefaultInit ");
- System.exit(1);
- }
-
-}
diff --git a/src/java/org/apache/log4j/test/DelayedLoop.java b/src/java/org/apache/log4j/test/DelayedLoop.java
deleted file mode 100644
index 3af6a48e8b..0000000000
--- a/src/java/org/apache/log4j/test/DelayedLoop.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.xml.DOMConfigurator;
-
-/**
- This test program sits in a loop and logs things. Its logging is
- configured by a configuration file. Changes to this configuration
- file are monitored and when a change occurs, the config file is re-read.
-
-
- @author Ceki Gülcü */
-public class DelayedLoop {
-
- static Category cat = Category.getInstance(DelayedLoop.class);
- static int loopLength;
-
- public
- static
- void main(String argv[]) {
-
- if(argv.length == 1)
- init(argv[0]);
- else
- usage("Wrong number of arguments.");
- test();
- }
-
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java " + DelayedLoop.class.getName() +
- "configFile");
- System.exit(1);
- }
-
-
- static
- void init(String configFile) {
- if(configFile.endsWith("xml")) {
- DOMConfigurator.configureAndWatch(configFile, 3000);
- } else {
- PropertyConfigurator.configureAndWatch(configFile, 3000);
- }
- }
-
- static
- void test() {
- int i = 0;
- while(true) {
- cat.debug("MSG "+i++);
- try {
- Thread.currentThread().sleep(1000);
- } catch(Exception e) {}
- }
- }
-}
diff --git a/src/java/org/apache/log4j/test/FQCNTest.java b/src/java/org/apache/log4j/test/FQCNTest.java
deleted file mode 100644
index 5d6a3377ef..0000000000
--- a/src/java/org/apache/log4j/test/FQCNTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.APL file.
- */
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.*;
-import org.apache.log4j.spi.*;
-//import org.apache.log4j.xml.examples.XPriority;
-
-/**
- This class is a shallow test of the various appenders and
- layouts. It also tests their reading of the configuration file.
- @author Ceki Gülcü
-*/
-public class FQCNTest {
-
- //static Logger cat = Logger.getLoggerInstance("dddd");
-
- public
- static
- void main(String argv[]) throws Exception {
- if(argv.length == 1)
- init(argv[0]);
- else
- usage("Wrong number of arguments.");
- test();
- }
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java "+ FQCNTest.class.getName()+"outputFile");
- System.exit(1);
- }
-
- static
- void init(String file) throws Exception {
- Layout layout = new PatternLayout("%p %c (%C{2}#%M) - %m%n");
- FileAppender appender = new FileAppender(layout, file, false);
- appender.setLayout(layout);
- Category root = Category.getRoot();
- root.addAppender(appender);
- }
-
-
- static
- void test() {
- X1Logger x1 = X1Logger.getX1Logger("x1");
- x1.debug("hello");
- x1.debug1("hello");
- x1.debug2("hello");
- }
-}
-
-
-// ==========================================================================
-// ==========================================================================
-// ==========================================================================
-
-class X1Logger extends Logger {
- static String FQCN = X1Logger.class.getName() + ".";
-
- private static X1LoggerFactory factory = new X1LoggerFactory();
-
- public X1Logger(String name) {
- super(name);
- }
-
- public
- void debug1(Object message) {
- super.log(FQCN, Priority.DEBUG, message + " world.", null);
- }
-
- public
- void debug2(Object message) {
- super.log(FQCN, Priority.DEBUG, message, null);
- }
-
- protected
- String getFQCN() {
- return X1Logger.FQCN;
- }
-
- public
- static
- X1Logger getX1Logger(String name) {
- return ((X1Logger) Logger.getLogger(name, factory));
- }
-}
-
-class X1LoggerFactory implements LoggerFactory {
-
- public
- X1LoggerFactory() {
- }
-
- public
- Logger makeNewLoggerInstance(String name) {
- return new X1Logger(name);
- }
-}
diff --git a/src/java/org/apache/log4j/test/Finalize.java b/src/java/org/apache/log4j/test/Finalize.java
deleted file mode 100644
index 3c9c8bab50..0000000000
--- a/src/java/org/apache/log4j/test/Finalize.java
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.Category;
-import java.io.InputStreamReader;
-import java.util.Enumeration;
-
-public class Finalize {
-
- static Category CAT = Category.getInstance(Finalize.class.getName());
-
- public
- static
- void main(String argv[]) {
-
- if(argv.length == 1)
- init(argv[0]);
- else
- Usage("Wrong number of arguments.");
-
- test();
- }
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java " + Finalize.class.getName() +
- " configFile");
- System.exit(1);
- }
-
-
- static
- void init(String configFile) {
- PropertyConfigurator.configure(configFile);
- }
-
- static
- void test() {
- int i = -1;
-
- InputStreamReader in = new InputStreamReader(System.in);
- Category root = Category.getRoot();
-
- System.out.println("Type 'q' to quit");
- int j = 0;
- while (true) {
- System.gc();
- try {i = in.read(); }
- catch(Exception e) { return; }
- System.gc();
- System.out.println("Read ["+i+"].");
- if(i == -1)
- break;
- else if(i == 'q')
- break;
- else
- root.debug("Hello " + (++j));
- }
-
- //foo(root);
- root.removeAllAppenders();
- System.gc(); delay(3000);
- System.gc(); delay(3000);
- System.gc(); delay(3000); System.gc();
- }
-
- static
- void foo(Category cat) {
- Enumeration enum = cat.getAllAppenders();
- while(enum != null && enum.hasMoreElements()) {
- ((org.apache.log4j.Appender) enum.nextElement()).close();
- }
- }
-
-
-
- static
- void delay(int amount) {
- try {
- Thread.currentThread().sleep(amount);
- }
- catch(Exception e) {}
- }
-
-}
diff --git a/src/java/org/apache/log4j/test/Hello.java b/src/java/org/apache/log4j/test/Hello.java
deleted file mode 100644
index ac663f3237..0000000000
--- a/src/java/org/apache/log4j/test/Hello.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.BasicConfigurator;
-
-/**
- Very simple log4j usage example.
-
- @author Ceki Gülcü
- */
-public class Hello {
-
- static Category cat = Category.getInstance(Hello.class);
-
- public
- static
- void main(String argv[]) {
- BasicConfigurator.configure();
- cat.debug("Hello world.");
- cat.info("What a beatiful day.");
- }
-}
diff --git a/src/java/org/apache/log4j/test/L7D.java b/src/java/org/apache/log4j/test/L7D.java
deleted file mode 100644
index edc663b546..0000000000
--- a/src/java/org/apache/log4j/test/L7D.java
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-// Copyright 1996-2000, International Business Machines
-// Corporation. All Rights Reserved.
-//
-// See the LICENCE file for the terms of distribution.
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.*;
-import java.util.*;
-import java.text.*;
-
-/**
- This class is a simple test of the localization routines in
- Category class.
-
- @author Ceki Gülcü, IBM Zurich Research Laboratory */
-public class L7D {
- static ResourceBundle[] bundles;
-
-
- public
- static
- void main(String args[]) {
- if(args.length == 3)
- init(args[0], args[1], args[2]);
- else
- Usage("Wrong number of arguments.");
-
- test();
- }
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java " + L7D.class.getName() +
- "configFile ISO639LanguageCode ISO2166CountryCode");
- System.exit(1);
- }
-
- static
- void init(String configFile, String lanCode, String countryCode) {
- PropertyConfigurator.configure(configFile);
- bundles = new ResourceBundle[3];
-
- try {
- bundles[0] = ResourceBundle.getBundle("L7D", new Locale("en", "US"));
- bundles[1] = ResourceBundle.getBundle("L7D", new Locale("fr", "FR"));
- bundles[2] = ResourceBundle.getBundle("L7D", new Locale("fr", "CH"));
-
- }
- catch(MissingResourceException e) {
- e.printStackTrace();
- }
- }
-
- static
- void test() {
- Category root = Category.getRoot();
-
- for(int i = 0; i < bundles.length; i++) {
- root.setResourceBundle(bundles[i]);
-
- root.l7dlog(Priority.DEBUG, "bogus1", null);
- root.l7dlog(Priority.INFO, "test", null);
- root.l7dlog(Priority.WARN, "hello_world", null);
- root.l7dlog(Priority.DEBUG, "msg1",
- new Object[] {new Integer(i+1), "log4j"}, null);
- root.l7dlog(Priority.ERROR, "bogusMsg",
- new Object[] {new Integer(i+1), "log4j"}, null);
- root.l7dlog(Priority.ERROR, "msg1",
- new Object[] {new Integer(i+1), "log4j"}, null);
- root.l7dlog(Priority.INFO, "bogus2", null);
- }
-
- }
-
-}
diff --git a/src/java/org/apache/log4j/test/L7D_en_US.properties b/src/java/org/apache/log4j/test/L7D_en_US.properties
deleted file mode 100644
index 4620e30e5f..0000000000
--- a/src/java/org/apache/log4j/test/L7D_en_US.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-test=This is the English, US test.
-hello_world=Hello world.
-msg1=This is test number {0} with string argument {1}.
diff --git a/src/java/org/apache/log4j/test/L7D_fr.properties b/src/java/org/apache/log4j/test/L7D_fr.properties
deleted file mode 100644
index 2e883c5c83..0000000000
--- a/src/java/org/apache/log4j/test/L7D_fr.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-test=Ceci est le test en francais pour la France.
-hello_world=Bonjour la France.
-msg1=Ceci est le test numero {0} contenant l''argument {1}.
diff --git a/src/java/org/apache/log4j/test/L7D_fr_CH.properties b/src/java/org/apache/log4j/test/L7D_fr_CH.properties
deleted file mode 100644
index 89293954d9..0000000000
--- a/src/java/org/apache/log4j/test/L7D_fr_CH.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-test=Ceci est le test en francais pour la p'tite Suisse.
-hello world=Salut le monde.
diff --git a/src/java/org/apache/log4j/test/MDCStress.java b/src/java/org/apache/log4j/test/MDCStress.java
deleted file mode 100644
index 9e7b97cd24..0000000000
--- a/src/java/org/apache/log4j/test/MDCStress.java
+++ /dev/null
@@ -1,143 +0,0 @@
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.*;
-
-
-import java.util.Random;
-
-public class MDCStress extends Thread {
-
- static Category root = Category.getRoot();
- static Category log = Category.getInstance(MDCStress.class);
-
- static Random random = new Random(17);
-
- static final int BRANCHING_FACTOR = 2;
- static final int LOOP_LENGTH = 12;
-
- static int maxThreads;
- static int threadCounter = 0;
- static int totalThreads = 0;
-
-
- public
- static
- void main(String args[]) {
-
- Layout layout = new PatternLayout("%r [%t] depth=%X{depth} total=%X{total} - %m%n");
- Appender appender = new ConsoleAppender(layout);
- root.addAppender(appender);
-
- if(args.length != 1) {
- usage();
- }
- try {
- maxThreads = Integer.parseInt(args[0]);
- }
- catch(java.lang.NumberFormatException e) {
- System.err.println(e);
- usage();
- }
-
- while(true) {
- synchronized(MDCStress.class) {
- // Adding 1 to ensure that at least 1 child is created.
- createChildren(randomInt(BRANCHING_FACTOR) + 1, 0);
-
- // wait until all threads are finished
- try {
- root.debug("About to wait for notification.");
- MDCStress.class.wait();
- root.debug( "Got a notification.");
- }
- catch(InterruptedException e) {
- root.warn("Unpextected InterruptedException received.", e);
- }
- }
- }
-
- }
-
- static
- void usage() {
- System.err.println( "Usage: "+MDCStress.class + " maxThreads");
- System.exit(1);
- }
-
-
- public
- static
- void createChildren(int n, int currentDepth) {
- if (n <= 0)
- return;
-
- synchronized(MDCStress.class) {
- n = maxThreadsConstained(n);
- for(int i = 0; i < n; i++) {
- threadCounter++;
- totalThreads++;
- log.debug("Creating Thread-"+(totalThreads-1));
- new MDCStress(currentDepth+1, totalThreads-1).start();
- }
- }
- }
-
-
- int depth;
- int total;
-
- MDCStress(int depth, int totalThreads) {
- this.depth = depth;
- this.total = totalThreads;
- }
-
- public
- void run() {
- log.debug("Entered run()");
-
- createChildren(randomInt(BRANCHING_FACTOR), depth);
-
- MDC.put("depth", new Integer(depth));
- MDC.put("total", new Integer(this.total));
-
- log.debug("Set MDC variables.");
-
- createChildren(randomInt(BRANCHING_FACTOR), depth);
-
-
- synchronized(MDCStress.class) {
- threadCounter--;
- root.debug("Exiting run loop. " + threadCounter);
- if(threadCounter <= 0) {
- MDCStress.class.notify(); // wake up the main thread
- }
- }
-
- }
-
-
- static
- public
- int maxThreadsConstained(int a) {
- int maxAllowed = MDCStress.maxThreads - MDCStress.threadCounter;
- return a <= maxAllowed ? a : maxAllowed;
- }
-
- /**
- Return a random value in the range
- */
- public
- static
- int randomInt(int n) {
- int r = random.nextInt() % n;
- return r >= 0 ? r : -r;
- }
-
- public
- static
- String randomID() {
- return Integer.toHexString(random.nextInt()& 0xFFFFFF);
- }
-
-}
diff --git a/src/java/org/apache/log4j/test/MultipleAppenders.java b/src/java/org/apache/log4j/test/MultipleAppenders.java
deleted file mode 100644
index 3ffd335e62..0000000000
--- a/src/java/org/apache/log4j/test/MultipleAppenders.java
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-package org.apache.log4j.test;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.Category;
-import org.apache.log4j.Appender;
-import java.util.Enumeration;
-import java.util.Vector;
-
-public class MultipleAppenders {
-
- public
- static
- void main(String argv[]) {
-
- // A1 and A2 should be added to root by reading the config file
- PropertyConfigurator.configure(argv[0]);
-
- Category root = Category.getRoot();
-
- Enumeration e1 = root.getAllAppenders();
- Vector v = new Vector(1);
-
- while(e1.hasMoreElements()) {
- Appender a = (Appender) e1.nextElement();
- v.addElement(a);
- String appenderName = a.getName();
- if(a != root.getAppender(appenderName)) {
- System.out.println(appenderName + " lookup failed. Exiting.");
- System.exit(1);
- }
- // attempt to add the existing appender
- root.addAppender(a);
- }
-
- // attempt to add a null appender
- root.addAppender(null);
-
- Enumeration e2 = root.getAllAppenders();
-
- for(int i = 0; i < v.size(); i++) {
- if(v.elementAt(i) != e2.nextElement()) {
- }
- }
-
- if(e2.hasMoreElements()){
- System.out.println("Failure, e2 has remaining elements. Exiting.");
- System.exit(1);
- }
- System.out.println("OK");
- }
-
-
-}
diff --git a/src/java/org/apache/log4j/test/PatternTest.java b/src/java/org/apache/log4j/test/PatternTest.java
deleted file mode 100644
index b7feaed044..0000000000
--- a/src/java/org/apache/log4j/test/PatternTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-
-package org.apache.log4j.test;
-
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.Category;
-import org.apache.log4j.Priority;
-/**
- This class is a test of the PatternLayout class.
-
- @author Ceki Gülcü
-*/
-public class PatternTest {
- static Category CAT = Category.getInstance(PatternTest.class);
-
-
- public
- static
- void main(String argv[]) {
-
- if(argv.length == 1)
- init(argv[0]);
- else
- Usage("Wrong number of arguments.");
-
- test();
- }
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java " + PatternTest.class.getName() +
- " configFile");
- System.exit(1);
- }
- static
- void init(String configFile) {
- PropertyConfigurator.configure(configFile);
- }
-
- static
- void test() {
- int i = -1;
- Category root = Category.getRoot();
-
- CAT.debug("Message " + ++i);
- root.debug("Message " + i);
-
- CAT.info ("Message " + ++i);
- root.info("Message " + i);
-
- CAT.warn ("Message " + ++i);
- root.warn("Message " + i);
-
- CAT.error("Message " + ++i);
- root.error("Message " + i);
-
- CAT.log(Priority.FATAL, "Message " + ++i);
- root.log(Priority.FATAL, "Message " + i);
-
- Exception e = new Exception("Just testing");
- CAT.debug("Message " + ++i, e);
- root.debug("Message " + i, e);
-
- CAT.info("Message " + ++i, e);
- root.info("Message " + i, e);
-
- CAT.warn("Message " + ++i , e);
- root.warn("Message " + i , e);
-
- CAT.error("Message " + ++i, e);
- root.error("Message " + i, e);
-
- CAT.log(Priority.FATAL, "Message " + ++i, e);
- root.log(Priority.FATAL, "Message " + i, e);
-
- Category.shutdown();
- }
-}
diff --git a/src/java/org/apache/log4j/test/PrintProperties.java b/src/java/org/apache/log4j/test/PrintProperties.java
deleted file mode 100644
index b6bfc7d4a5..0000000000
--- a/src/java/org/apache/log4j/test/PrintProperties.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file.
- */
-
-package org.apache.log4j.test;
-
-import java.io.*;
-import org.apache.log4j.config.PropertyPrinter;
-
-/**
- Prints the configuration of the log4j default hierarchy
- (which needs to be auto-initialized) as a propoperties file
- on System.out.
-
- @author Anders Kristensen
- */
-public class PrintProperties {
- public
- static
- void main(String[] args) {
- new PropertyPrinter(new PrintWriter(System.out), true);
- }
-}
\ No newline at end of file
diff --git a/src/java/org/apache/log4j/test/README b/src/java/org/apache/log4j/test/README
deleted file mode 100644
index ece49e2ff2..0000000000
--- a/src/java/org/apache/log4j/test/README
+++ /dev/null
@@ -1,9 +0,0 @@
-
-The log4j test suite has been verfied to run on both Windows NT/2000
-and Linux. However, the suite requires the bash shell and perl. On
-most Unix systems these are included by default. On Windows systems
-you nedd to install the Cygwin tools from
-
- http://sources.redhat.com/cygwin
-
-In case of problems send an e-mail note to log4j-dev@jakarta.apache.org.
diff --git a/src/java/org/apache/log4j/test/ROFile.java b/src/java/org/apache/log4j/test/ROFile.java
deleted file mode 100644
index 4f36a0fb32..0000000000
--- a/src/java/org/apache/log4j/test/ROFile.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.log4j.test;
-
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.Category;
-
-public class ROFile {
-
- static Category cat = Category.getInstance(ROFile.class.getName());
-
- public
- static
- void main(String argv[]) {
-
- if(argv.length == 1)
- init(argv[0]);
- else
- Usage("Wrong number of arguments.");
-
- test();
- }
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java " + ROFile.class.getName() +
- "configFile");
- System.exit(1);
- }
-
- static
- void init(String configFile) {
- PropertyConfigurator.configure(configFile);
- }
-
- static
- void test() {
- int i = -1;
- cat.debug("Message " + ++i);
- }
-}
diff --git a/src/java/org/apache/log4j/test/Shallow.java b/src/java/org/apache/log4j/test/Shallow.java
deleted file mode 100644
index 2a202d0384..0000000000
--- a/src/java/org/apache/log4j/test/Shallow.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
- */
-// NOTICE: Some tests are sensitive to line numbers!
-package org.apache.log4j.test;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.xml.DOMConfigurator;
-import org.apache.log4j.Category;
-import org.apache.log4j.NDC;
-import org.apache.log4j.Priority;
-/**
- This class is a shallow test of the various appenders and
- layouts. It also tests their reading of the configuration file.
- @author Ceki Gülcü
-*/
-public class Shallow {
-
- static Category cat = Category.getInstance(Shallow.class);
-
- public
- static
- void main(String argv[]) {
- if(argv.length == 1)
- init(argv[0]);
- else
- usage("Wrong number of arguments.");
- test();
- }
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java "+ Shallow.class.getName()+"configFile");
- System.exit(1);
- }
-
- static
- void init(String configFile) {
- if(configFile.endsWith(".xml"))
- DOMConfigurator.configure(configFile);
- else
- PropertyConfigurator.configure(configFile);
- }
-
- static
- void test() {
- int i = -1;
- NDC.push("NDC");
- Category root = Category.getRoot();
- cat.debug("Message " + ++i);
- root.debug("Message " + i);
-
- cat.info ("Message " + ++i);
- root.info("Message " + i);
-
- cat.warn ("Message " + ++i);
- root.warn("Message " + i);
-
- cat.error("Message " + ++i);
- root.error("Message " + i);
-
- cat.log(Priority.FATAL, "Message " + ++i);
- root.log(Priority.FATAL, "Message " + i);
-
- Exception e = new Exception("Just testing");
- cat.debug("Message " + ++i, e);
- root.debug("Message " + i, e);
-
- cat.info("Message " + ++i, e);
- root.info("Message " + i, e);
-
- cat.warn("Message " + ++i , e);
- root.warn("Message " + i , e);
-
- cat.error("Message " + ++i, e);
- root.error("Message " + i, e);
-
- cat.log(Priority.FATAL, "Message " + ++i, e);
- root.log(Priority.FATAL, "Message " + i, e);
-
- root.setPriority(Priority.FATAL);
-
- // It is always a good idea to call this method when exiting an
- // application.
- Category.shutdown();
- }
-
-
- static
- void delay(int amount) {
- try {
- Thread.currentThread().sleep(amount);
- }
- catch(Exception e) {}
- }
-}
diff --git a/src/java/org/apache/log4j/test/ShortSocketServer.java b/src/java/org/apache/log4j/test/ShortSocketServer.java
deleted file mode 100644
index e1ba36bc35..0000000000
--- a/src/java/org/apache/log4j/test/ShortSocketServer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
-package org.apache.log4j.test;
-
-import java.net.Socket;
-import java.net.ServerSocket;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.net.SocketNode;
-
-/**
-*/
-
-public class ShortSocketServer {
-
- static Category cat = Category.getInstance(ShortSocketServer.class.getName());
-
- static int port;
-
- public
- static
- void main(String argv[]) {
- if(argv.length == 2) {
- init(argv[0], argv[1]);
- } else {
- usage("Wrong number of arguments.");
- }
-
- try {
- LogLog.debug("Listening on port " + port);
- ServerSocket serverSocket = new ServerSocket(port);
- LogLog.debug("Waiting to accept a new client.");
- Socket socket = serverSocket.accept();
- LogLog.debug("Connected to client at " + socket.getInetAddress());
- LogLog.debug("Starting new socket node.");
- SocketNode sn = new SocketNode(socket, Category.getDefaultHierarchy());
- Thread t = new Thread(sn);
- t.start();
- t.join();
- }
- catch(Exception e) {
- cat.error("Error while in main.", e);
- }
- }
-
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println(
- "Usage: java " +ShortSocketServer.class.getName() + " port configFile");
- System.exit(1);
- }
-
- static
- void init(String portStr, String configFile) {
- try {
- port = Integer.parseInt(portStr);
- }
- catch(java.lang.NumberFormatException e) {
- e.printStackTrace();
- usage("Could not interpret port number ["+ portStr +"].");
- }
- PropertyConfigurator.configure(configFile);
- }
-}
diff --git a/src/java/org/apache/log4j/test/SpacePad.java b/src/java/org/apache/log4j/test/SpacePad.java
deleted file mode 100644
index 91a9989d5a..0000000000
--- a/src/java/org/apache/log4j/test/SpacePad.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.apache.log4j.test;
-
-public class SpacePad {
-
- static String[] SPACES = {" ", " ", " ", " ", //1,2,4,8 spaces
- " ", // 16 spaces
- " " }; // 32
-
- static public void main(String[] args) {
- StringBuffer sbuf = new StringBuffer();
-
- for(int i = 0; i < 35; i++) {
- sbuf.setLength(0);
- sbuf.append("\"");
- spacePad(sbuf, i);
- sbuf.append("\"");
- System.out.println(sbuf.toString());
- }
-
- sbuf.setLength(0);
- sbuf.append("\"");
- spacePad(sbuf, 67);
- sbuf.append("\"");
- System.out.println(sbuf.toString());
-
- }
- static
- public
- void spacePad(StringBuffer sbuf, int length) {
- //LogLog.debug("Padding with " + length + " spaces.");
- while(length >= 32) {
- sbuf.append(SPACES[5]);
- length -= 32;
- }
-
- for(int i = 4; i >= 0; i--) {
- if((length & (1<> $TEMP.x
- mv $TEMP.x $TEMP
- fi
-
- $PERL filter.pl $TEMP $OUTPUT ConfigurationFileParsing $options
- if [ $? != 0 ]; then
- echo "The output is not in expected format. See the file [$OUTPUT]."
- exit 1
- fi
-
- check witness/confParsing.$TEST $OUTPUT; echo " OK"
-}
-
-
-# =========================================================================
-# Just run ConfigurationFileParsing and direct the output to STDOUT or
-# STDERR.
-# =========================================================================
-function testConfigurationParsingII {
- conf=$1;
- target=$2
-
- case $target in
- OUT )
- java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $conf>$TEMP
- ;;
- ERR )
- java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $conf>& $TEMP
- ;;
- esac
-
- check witness/confParsing.$TEST $TEMP; echo " OK"
-}
-# ======================================================
-
-declare -i TEST
-
-
-TEST=1;
-if [ $TEST -ge $start ]; then
- D_FLAG=$DEF_DEBUG
- echo "log4j.rootCategory=DEBUG, testAppender" > $LCF
- lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
- lecho "log4j.appender.testAppender.File= $TEMP"
- lecho "log4j.appender.testAppender.Append=false"
- lecho "log4j.appender.testAppender.layout.ContextPrinting= false "
- lecho "log4j.appender.testAppender.layout.ThreadPrinting= xx "
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout "
- testConfigurationParsing $LCF LINE_NUMBER
-fi
-
-TEST=2;
-if [ $TEST -ge $start ]; then
- D_FLAG=$DEF_DEBUG
- echo "log4j.rootCategory=DEBUG, testAppender" > $LCF
- lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
- lecho "log4j.appender.testAppender.File= $TEMP"
- lecho "log4j.appender.testAppender.Append=false"
- lecho "log4j.appender.testAppender.MaxFileSize=1KB"
- lecho "log4j.appender.testAppender.MaxBackupIndex= 1 "
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
- lecho "log4j.appender.testAppender.layout.ThreadPrinting=true"
- lecho "log4j.appender.testAppender.layout.DateFormat=ReLaTIve"
- testConfigurationParsing $LCF RELATIVE
-fi
-
-TEST=3;
-if [ $TEST -ge $start ]; then
- D_FLAG=$DEF_DEBUG
- echo "18:25:32.394 [main] DEBUG testing - HELLO WORLD" > $TEMP
- echo "log4j.rootCategory=DEBUG, testAppender" > $LCF
- lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
- lecho "log4j.appender.testAppender.File=$TEMP"
- lecho "log4j.appender.testAppender.Append=true"
- lecho "log4j.appender.testAppender.MaxFileSize=54"
- lecho "log4j.appender.testAppender.MaxBackupIndex= 0 "
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
- lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute"
- lecho "log4j.appender.testAppender.layout.TimeZone=GMT"
- testConfigurationParsing $LCF ABSOLUTE
-fi
-
-
-TEST=4;
-if [ $TEST -ge $start ]; then
- D_FLAG=$DEF_DEBUG
- echo "18:25:32,394 [main] DEBUG testing - HELLO WORLD" > $TEMP
- echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
- lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
- lecho "log4j.appender.testAppender.File=$TEMP"
- lecho "log4j.appender.testAppender.Append=true"
- lecho "log4j.appender.testAppender.MaxFileSize=155"
- lecho "log4j.appender.testAppender.MaxBackupIndex=0"
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
- lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute"
- lecho "log4j.appender.testAppender.layout.TimeZone=ECT"
- testConfigurationParsing $LCF ABSOLUTE
-fi
-
-
-TEST=5;
-if [ $TEST -ge $start ]; then
- D_FLAG=""
- echo "18:25:32,394 [main] DEBUG testing - HELLO WORLD" > $TEMP
- echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
- lecho "log4j.debug="
- lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
- lecho "log4j.appender.testAppender.File=$TEMP"
- lecho "log4j.appender.testAppender.Append= true"
- lecho "log4j.appender.testAppender.MaxFileSize= 1 "
- lecho "log4j.appender.testAppender.MaxBackupIndex= 2"
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
- lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute"
- lecho "log4j.appender.testAppender.layout.TimeZone=ECT"
- testConfigurationParsing $LCF ABSOLUTE $TEMP.2 $TEMP.1
-fi
-
-TEST=6;
-if [ $TEST -ge $start ]; then
- D_FLAG=""
- echo "log4j.rootCategory= , testAppender" > $LCF
- lecho "log4j.debug="
- lecho "log4j.appender.testAppender=org.apache.log4j.FileAppender"
- lecho "log4j.appender.testAppender.File=$TEMP"
- lecho "log4j.appender.testAppender.Append= false "
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
- lecho "log4j.appender.testAppender.layout.DateFormat=dAtE"
- lecho "log4j.appender.testAppender.layout.TimeZone="
-
- testConfigurationParsing $LCF DATE
-fi
-
-
-TEST=7;
-if [ $TEST -ge $start ]; then
- D_FLAG=""
- echo "18:25:32,394 [main] DEBUG testing - HELLO WORLD" > $TEMP
- echo "log4j.rootCategory= DEBUG , testAppender, inexistentAppender" > $LCF
- lecho "log4j.debug=false"
- lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
- lecho "log4j.appender.testAppender.File=$TEMP"
- lecho "log4j.appender.testAppender.Append= true"
- lecho "log4j.appender.testAppender.MaxFileSize= 1 "
- lecho "log4j.appender.testAppender.MaxBackupIndex=2 "
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
- lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute"
- lecho "log4j.appender.testAppender.layout.TimeZone=ECT"
-
- testConfigurationParsing $LCF ABSOLUTE $TEMP.2 $TEMP.1
-fi
-
-
-TEST=8;
-if [ $TEST -ge $start ]; then
- D_FLAG=""
- echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
- lecho "log4j.debug=false"
- lecho "log4j.appender.testAppender=org.apache.log4j.ConsoleAppender"
- # Note the spaces
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout "
- lecho "log4j.appender.testAppender.layout.ConversionPattern=[%t] %p - %m%n"
- echo -n " ConfigurationParsing test $TEST - "
- testConfigurationParsingII $LCF OUT
-fi
-
-TEST=9;
-if [ $TEST -ge $start ]; then
- D_FLAG=""
- echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
- lecho "log4j.debug=false"
- lecho "log4j.appender.testAppender=org.apache.log4j.ConsoleAppender"
- lecho "log4j.appender.testAppender.Target= System.out "
-# lecho "log4j.appender.testAppender.Append= true "
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout"
- lecho "log4j.appender.testAppender.layout.ConversionPattern=[%t] %p - %m%n"
- echo -n " ConfigurationParsing test $TEST (can fail if anything is written to System.err) - "
- testConfigurationParsingII $LCF ERR
-fi
-
-# Test variable subst from System properties
-TEST=10;
-if [ $TEST -ge $start ]; then
- D_FLAG=""
- echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
- lecho "log4j.debug=false"
- lecho "log4j.appender.testAppender=org.apache.log4j.FileAppender"
- # We escape the dollar sign to avoid substitution at the shell level.
- lecho "log4j.appender.testAppender.File=\${user.dir}/$TEMP"
- lecho "log4j.appender.testAppender.Append=false"
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout"
- lecho "log4j.appender.testAppender.layout.ConversionPattern=AVY [%t] %p-%m%n"
- testConfigurationParsing $LCF NONE
-fi
-
-rm $TEMP > /dev/null
-
-# Test variable subst from the config file itself
-TEST=11;
-if [ $TEST -ge $start ]; then
- D_FALG=""
- echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
- lecho "log4j.configDebug=false"
- # $TEMP will be replaced by the shell
- lecho "t=$TEMP"
- lecho "log4j.appender.testAppender=org.apache.log4j.FileAppender"
- # We escape the dollar sign to avoid substitution at the shell level.
- lecho "log4j.appender.testAppender.File=\${t}"
- lecho "log4j.appender.testAppender.Append=false"
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout"
- lecho "log4j.appender.testAppender.layout.ConversionPattern=VSUB [%t] %p-%m%n"
- testConfigurationParsing $LCF NONE
-fi
-
-
-
-
-
-
-
-
-
-
-
-# Do SyslogAppender test (not real tests)
-
-TEST=100;
-
-if [ $TEST -ge $start ]; then
- D_FLAG=""
- echo "log4j.rootCategory= , testAppender" > $LCF
- lecho "log4j.debug=true"
- lecho "log4j.appender.testAppender=org.apache.log4j.net.SyslogAppender"
- lecho "log4j.appender.testAppender.SyslogHost=localhost"
- lecho "log4j.appender.testAppender.Facility= LOCAL0 "
- lecho "log4j.appender.testAppender.FacilityPrinting=true"
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
- lecho "log4j.appender.testAppender.layout.DateFormat=NULL"
- lecho "log4j.appender.testAppender.layout.TimeZone="
-
- echo -n " ConfigurationParsing test $TEST - "
- java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $LCF
-fi
-
-
-TEST=101;
-
-if [ $TEST -ge $start ]; then
- D_FLAG=""
- echo "log4j.rootCategory= , testAppender" > $LCF
- lecho "log4j.debug=true"
- lecho "log4j.appender.testAppender=org.apache.log4j.net.SyslogAppender"
- lecho "log4j.appender.testAppender.SyslogHost=localhost"
- lecho "log4j.appender.testAppender.Facility="
- lecho "log4j.appender.testAppender.FacilityPrinting="
- lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
- lecho "log4j.appender.testAppender.layout.DateFormat=NULL"
- lecho "log4j.appender.testAppender.layout.TimeZone="
-
- echo -n " ConfigurationParsing test $TEST - "
- java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $LCF
-fi
diff --git a/src/java/org/apache/log4j/test/customCategory b/src/java/org/apache/log4j/test/customCategory
deleted file mode 100644
index 36adae9eb3..0000000000
--- a/src/java/org/apache/log4j/test/customCategory
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-
-# A regression test to check support custom priorities
-
-# Read the .functions file
-. .functions
-
-# If set, allows to skip tests
-declare -i start=$1
-echo "start=$start TEMP=$TEMP OUTPUT=$OUTPUT"
-
-function testCustomCat {
- layout=$1
-
- echo -n "Custom Priority test $TEST - "
- java -Dlog4j.debug org.apache.log4j.test.CustomCategoryTest $LCF
-
- check witness/customCat.$TEST $TEMP; echo "OK."
-}
-
-
-
-setPERL
-
-declare -i TEST
-
-TEST=1
-if [ $TEST -ge $start ]; then
- echo "LOG4J=org.apache.log4j" > $LCF
- lecho "log4j.rootCategory=TRACE#\${LOG4J}.xml.examples.XLevel, testAppender"
- lecho "log4j.loggerFactory=\${LOG4J}.xml.examples.XLogger\$XFactory"
- lecho "log4j.appender.testAppender=\${LOG4J}.FileAppender"
- lecho "log4j.appender.testAppender=\${LOG4J}.FileAppender"
- lecho "log4j.appender.testAppender.File=$TEMP"
- lecho "log4j.appender.testAppender.Append=false"
- lecho "log4j.appender.testAppender.layout=\${LOG4J}.PatternLayout "
- lecho "log4j.appender.testAppender.layout.ConversionPattern=%-5p - %m%n"
- testCustomCat
-fi
-
-
-
diff --git a/src/java/org/apache/log4j/test/defaultInit b/src/java/org/apache/log4j/test/defaultInit
deleted file mode 100644
index e05628d855..0000000000
--- a/src/java/org/apache/log4j/test/defaultInit
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-
-# Read the .functions file
-. .functions
-
-# If set, allows to skip tests
-declare -i start=$1
-
-# ==================================================
-function testDefaultInit {
- echo -n "Default initialization test $TEST - "
-
- if [ -e $TEMP ]; then
- #echo "Deleting $TEMP."
- rm $TEMP
- touch $TEMP
- fi
-
- java $1 -Dlog4j.debug org.apache.log4j.test.DefaultInit
-
- check witness/definit.$TEST $TEMP; echo "OK."
-}
-# ==================================================
-
-
-declare -i TEST
-
-function createProperties {
- echo "log4j.rootCategory=DEBUG, A1" > $LCF
- lecho "log4j.appender.A1=org.apache.log4j.FileAppender"
- lecho "log4j.appender.A1.File=$TEMP"
- lecho "log4j.appender.A1.Append=false"
- lecho "log4j.appender.A1.layout=org.apache.log4j.PatternLayout "
- lecho "log4j.appender.A1.layout.ConversionPattern=%m%n"
-}
-
-LCF=log4j.properties
-createProperties
-
-TEST=1
-if [ $TEST -ge $start ]; then
- testDefaultInit
-fi
-
-TEST=2
-if [ $TEST -ge $start ]; then
- testDefaultInit -Dlog4j.defaultInitOverride
-fi
-
-TEST=3
-if [ $TEST -ge $start ]; then
- testDefaultInit -Dlog4j.defaultInitOverride=true
-fi
-
-TEST=4
-if [ $TEST -ge $start ]; then
- testDefaultInit -Dlog4j.defaultInitOverride=
-fi
-
-TEST=5
-if [ $TEST -ge $start ]; then
- testDefaultInit -Dlog4j.defaultInitOverride=false
-fi
-
-rm $LCF
-
-LCF=props
-createProperties
-
-TEST=6
-if [ $TEST -ge $start ]; then
- testDefaultInit -Dlog4j.configuration=props
-fi
-
-rm $LCF
diff --git a/src/java/org/apache/log4j/test/domTest b/src/java/org/apache/log4j/test/domTest
deleted file mode 100644
index adf10088de..0000000000
--- a/src/java/org/apache/log4j/test/domTest
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/bash
-
-# A regression test to check the PatternLayout code.
-
-# Read the .functions
-. .functions
-
-
-# If set, allows to skip tests
-declare -i start=$1
-
-echo "start=$start TEMP=$TEMP OUTPUT=$OUTPUT"
-# ==================================================================
-function testDOM {
-
- configFile=$1
- layoutA1=$2
- layoutA2=$3
-
- deleteFile temp.A1 > /dev/null; deleteFile output.A1 > /dev/null ;
- deleteFile temp.A2 > /dev/null; deleteFile output.A2 > /dev/null;
- touch temp.A1 temp.A2
-
- echo -n "DOM test $TEST - "
- #java org.apache.log4j.xml.test.DOMTest $configFile
- java -Dlog4j.configDebug org.apache.log4j.xml.test.DOMTest $configFile
-
- $PERL filter.pl temp.A1 output.A1 DOMTest $layoutA1
- if [ $? != 0 ]; then
- echo "The output(1) is not in expected format. See the file [output.A1]."
- exit 1
- fi
-
- $PERL filter.pl temp.A2 output.A2 DOMTest $layoutA2
- if [ $? != 0 ]; then
- echo "The output(2) is not in expected format. See the file [output.A2]."
- exit 1
- fi
-
-
- check witness/domTest.A1.$TEST output.A1; echo -n "-"
- check witness/domTest.A2.$TEST output.A2; echo " OK"
-
-}
-# ==================================================================
-function simpleTest {
-
- configFile=$1
-
- echo -n "DOM test $TEST - "
- java org.apache.log4j.xml.test.DOMTest $configFile
- #java -Dlog4j.configDebug org.apache.log4j.xml.test.DOMTest $configFile
- $PERL filter.pl $TEMP $OUTPUT DOMTest LINE_NUMBER
-
- check witness/domTest.$TEST $OUTPUT; echo " OK"
-
-}
-# ==================================================================
-
-
-setPERL
-
-declare -i TEST
-
-TEST=1
-if [ $TEST -ge $start ]; then
- testDOM xml/domTest$TEST.xml LINE_NUMBER ISO8601
-fi
-
-TEST=2
-if [ $TEST -ge $start ]; then
- echo "THIS TEST WILL ECHO WARNINGS (BUT DOES NOT THROW EXCEPTIONS)."
- testDOM xml/domTest$TEST.xml LINE_NUMBER ISO8601
-fi
-
-TEST=3
-if [ $TEST -ge $start ]; then
- testDOM xml/domTest$TEST.xml RELATIVE RELATIVE
-fi
-
-for TEST in 4 5 6 7 8 9 10 11 12
-do
- if [ $TEST -ge $start ]; then
- simpleTest xml/domTest$TEST.xml
- fi
-done
-
-
diff --git a/src/java/org/apache/log4j/test/drfa b/src/java/org/apache/log4j/test/drfa
deleted file mode 100644
index c3ce23094f..0000000000
--- a/src/java/org/apache/log4j/test/drfa
+++ /dev/null
@@ -1,36 +0,0 @@
-if [ -z "$PERL" ]
-then
- PERL=perl
-fi
-
-. .functions
-
-#rm test
-#rm test.*
-
-echo "starting org.apache.log4j.test.DRFATest 5"
-java -Dlog4j.debug org.apache.log4j.test.DRFATest 5
-$PERL drfa.pl || die "drfa test FAILED."
-
-echo -n "About to sleep ";date
-sleep 60
-echo -n "After sleep ";date
-echo "Starting org.apache.log4j.test.DRFATest 10"
-java -Dlog4j.debug org.apache.log4j.test.DRFATest 10
-$PERL drfa.pl || die "drfa test FAILED."
-
-
-echo -n "About to sleep ";date
-sleep 60
-echo -n "After sleep ";date
-echo "Starting org.apache.log4j.test.DRFATest 100"
-java -Dlog4j.debug org.apache.log4j.test.DRFATest 100
-$PERL drfa.pl || die "drfa test FAILED."
-
-
-echo -n "About to sleep ";date
-sleep 60
-echo -n "After sleep ";date
-echo "Starting org.apache.log4j.test.DRFATest 100"
-java -Dlog4j.debug org.apache.log4j.test.DRFATest 100
-$PERL drfa.pl || die "drfa test FAILED."
diff --git a/src/java/org/apache/log4j/test/drfa.pl b/src/java/org/apache/log4j/test/drfa.pl
deleted file mode 100644
index 5ee1a2b547..0000000000
--- a/src/java/org/apache/log4j/test/drfa.pl
+++ /dev/null
@@ -1,45 +0,0 @@
-
-$|=1;
-
-while($next = \d+<\/td>/) {
- s/ \d+<\/td>/ XXX<\/td>/;
- }
- print OUT ;
- }
-}
-
-sub doLineNumberFilter {
- while(
-
-
-Last modified: Tue Nov 16 20:26:36 MET 1999
-
-
diff --git a/src/java/org/apache/log4j/test/propConfig b/src/java/org/apache/log4j/test/propConfig
deleted file mode 100644
index 447e0fab6d..0000000000
--- a/src/java/org/apache/log4j/test/propConfig
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/bash
-
-# Read the .functions file
-. .functions
-
-# If set, allows to skip tests
-declare -i start=$1
-
-# ==================================================
-function testPropConfig {
- echo -n "PropertyConfiguratorInterface test $TEST - "
-
- if [ -e $TEMP ]; then
- #echo "Deleting $TEMP."
- rm $TEMP
- touch $TEMP
- fi
-
- java $* org.apache.log4j.test.DefaultInit > $TEMP
- check witness/propCfg.$TEST $TEMP; echo "OK."
-}
-# ==================================================
-
-
-declare -i TEST
-
-LCF=log4j.properties
-
-function createProperties {
- echo "" > $LCF
- lecho "log4j.rootLogger=DEBUG, A1"
- lecho "log4j.appender.A1=org.apache.log4j.FileAppender"
- lecho "log4j.appender.A1.File=$TEMP"
- lecho "log4j.appender.A1.Append=false"
- lecho "log4j.appender.A1.layout=org.apache.log4j.PatternLayout "
- lecho "log4j.appender.A1.layout.ConversionPattern=%m%n"
-}
-
-createProperties
-
-TEST=1
-if [ $TEST -ge $start ]; then
- testPropConfig
-fi
-
-#org.apache.log4j.test.SysoutConfigurator
-
-TEST=2
-if [ $TEST -ge $start ]; then
- testPropConfig -Dlog4j=debug -Dlog4j.configuration=file:$LCF -Dlog4j.configuratorClass=org.apache.log4j.test.SysoutConfigurator
-fi
-
-
-rm $LCF
diff --git a/src/java/org/apache/log4j/test/roTest b/src/java/org/apache/log4j/test/roTest
deleted file mode 100644
index 94cb9f5aa2..0000000000
--- a/src/java/org/apache/log4j/test/roTest
+++ /dev/null
@@ -1,30 +0,0 @@
-
-# A regression test to check the option reading code and print formats.
-
-# Read the .functions file
-. .functions
-
-A1_PREFIX="log4j.appender.A1"
-
-# ----------------------------------------------------------------------
-function testRO {
- confFile=$1
-
- echo -n "ReadOnlyFile test $TEST - "
- java -Dlog4j.configDebug org.apache.log4j.test.ROFile $confFile
-
-}
-
-touch readonly
-chmod -w readonly
-
-echo "$A1_PREFIX=org.apache.log4j.RollingFileAppender" > $LCF
-lecho "$A1_PREFIX.Append=true"
-lecho "$A1_PREFIX.File=readonly"
-lecho "$A1_PREFIX.layout=org.apache.log4j.PatternLayout"
-lecho "$A1_PREFIX.layout.ConversionPattern=%p [%t] = %m"
-lecho "$ROOT_PREFIX=DEBUG, A1"
-testRO $LCF
-
-rm -f readonly
-
diff --git a/src/java/org/apache/log4j/test/runAll b/src/java/org/apache/log4j/test/runAll
deleted file mode 100644
index 0b44b94185..0000000000
--- a/src/java/org/apache/log4j/test/runAll
+++ /dev/null
@@ -1,19 +0,0 @@
-
-#!/bin/sh
-
-. .functions
-
-deleteFile log4j.properties
-
-./shallow || die "shallow test FAILED."
-./defaultInit || die "defaultInit test FAILED."
-./propConfig || die "propConfig test FAILED."
-./getOptions || die "getOptions test FAILED."
-./domTest || die "domTest FAILED."
-./multipleAppenders || die "multipleAppenders test FAILED."
-./confParsing || die "confParsing test FAILED."
-#./customCategory || die "customCategory test FAILED."
-./mycat || die "mycat test FAILED."
-./l7d || die "L7D test FAILED."
-./fqcn || die "FQCN test FAILED."
-#./extSupport || die "Extension support test FAILED."
diff --git a/src/java/org/apache/log4j/test/serialization/README b/src/java/org/apache/log4j/test/serialization/README
deleted file mode 100644
index 4c8b23e435..0000000000
--- a/src/java/org/apache/log4j/test/serialization/README
+++ /dev/null
@@ -1,36 +0,0 @@
- =======================
- Serialization unit test
- =======================
-
-Running the serialization test is not for the faint of heart. It is
-complicated because we are trying to read or write two different
-versions of the same class. This requires unusual classloading
-techniques.
-
-Compiling
-=========
-
-step1)
-
-The file SerializationUT.java must be compiled with only the Java
-rt.jar and junit.jar on the class path. The compilation must be
-carried out from the directory where this README file is located.
-
-step2)
-
-Compile the files T/T113.java and T/T12.java. See the files
-compile.sample.bat and compile.sample.sh under the T/
-directory. Compilations must be carried in T/.
-
-Running
-=======
-Tests use the same classpath and are run as follows:
-
- 1) cd to $LOG4J_HOME/src/java/org/apache/log4j/test/serialization
-
- This is where this README file is located.
-
- 2) Run
-
- java junit.textui.TestRunner SerializationUT
-
diff --git a/src/java/org/apache/log4j/test/serialization/SerializationUT.java b/src/java/org/apache/log4j/test/serialization/SerializationUT.java
deleted file mode 100644
index 5bf529a298..0000000000
--- a/src/java/org/apache/log4j/test/serialization/SerializationUT.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.framework.Test;
-import java.util.Hashtable;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.lang.reflect.Method;
-
-/**
- The SerializationUnitTest checks whether the {@link LoggingEvent}
- objects are compatible across different log4j versions.
-
- @author Ceki Gülcü
-
-*/
-public class SerializationUT extends TestCase {
-
- // String categoryName
- // String ndc
- // boolan ndcLookupRequired
- // String renderedMessage
- // String threadName
- // long timeStamp
-
-
- static URLClassLoader classLoader113;
- static Class class113;
- static Object o113;
- static Method serMethod113;
- static Method deserMethod113;
-
- static URLClassLoader classLoader12a7;
- static Class class12a7;
- static Object o12a7;
- static Method serMethod12a7;
- static Method deserMethod12a7;
-
- public SerializationUT(String name) {
- super(name);
- }
-
- public
- void setUp() throws Exception {
-
- try {
- URL urlLocal = new URL("file:T/");
-
- URL url113 = new URL("file:T/log4j-1.1.3.jar");
-
- classLoader113 = new URLClassLoader(new URL[] {urlLocal, url113});
- class113 = classLoader113.loadClass("T113");
- o113 = class113.newInstance();
- serMethod113 = class113.getMethod("serialize",
- new Class[] {java.util.Hashtable.class});
-
- deserMethod113 = class113.getMethod("deserialize",
- new Class[] {byte[].class});
-
-
- URL url2a7 = new URL("file:T/log4j-1.2alpha7.jar");
-
- classLoader12a7 = new URLClassLoader(new URL[] {urlLocal, url2a7});
- class12a7 = classLoader12a7.loadClass("T12");
- o12a7 = class12a7.newInstance();
- serMethod12a7 = class12a7.getMethod("serialize",
- new Class[] {java.util.Hashtable.class});
- deserMethod12a7 = class12a7.getMethod("deserialize",
- new Class[] {byte[].class});
- } catch(Exception e) {
- e.printStackTrace();
- throw e;
- }
-
- System.out.println("---Exiting setup");
- }
-
- public
- void tearDown() {
- }
-
-
- /**
- Test writing in 1.1.3 and reading from 1.1.3. Here we are testing
- the test. */
- public
- void test1() throws Exception {
-
- Hashtable inHt = new Hashtable();
- Hashtable witness = new Hashtable();
-
- inHt.put("categoryName", "a.b.c");
- inHt.put("priorityStr", "DEBUG");
- inHt.put("message", "hello");
-
- witness.put("categoryName", "a.b.c");
- witness.put("priorityStr", "DEBUG");
- witness.put("renderedMessage", "hello");
-
- byte[] buf = (byte[]) serMethod113.invoke(o113, new Object[] {inHt});
-
- Hashtable outHt = (Hashtable) deserMethod113.invoke(o113, new Object[] {buf});
-
- System.out.println("witness"+witness);
- System.out.println("outHt "+outHt);
-
- assertEquals(witness, outHt);
- }
-
- /**
- Test writing 1.2 and reading from 1.2. Here we are testing the test.
- */
- public
- void test2() throws Exception {
-
- Hashtable inHt = new Hashtable();
- Hashtable witness = new Hashtable();
-
- inHt.put("categoryName", "a.b.c");
- inHt.put("priorityStr", "DEBUG");
- inHt.put("message", "hello");
-
- witness.put("categoryName", "a.b.c");
- witness.put("priorityStr", "DEBUG");
- witness.put("renderedMessage", "hello");
-
- byte[] buf = (byte[]) serMethod12a7.invoke(o12a7, new Object[] {inHt});
-
- Hashtable outHt = (Hashtable) deserMethod12a7.invoke(o12a7, new Object[] {buf});
- assertEquals(witness, outHt);
- }
-
- /**
- Test writing 1.1.3 and reading from 1.2.
- */
- public
- void test3() throws Exception {
-
- Hashtable inHt = new Hashtable();
- Hashtable witness = new Hashtable();
-
- inHt.put("categoryName", "a.b.c");
- inHt.put("priorityStr", "DEBUG");
- inHt.put("message", "hello");
-
- witness.put("categoryName", "a.b.c");
- witness.put("priorityStr", "DEBUG");
- witness.put("renderedMessage", "hello");
- byte[] buf = (byte[]) serMethod113.invoke(o113, new Object[] {inHt});
- Hashtable outHt = (Hashtable) deserMethod12a7.invoke(o12a7, new Object[] {buf});
- assertEquals(witness, outHt);
- }
-
- /**
- Test writing 1.2 and reading from 1.1.3.
- */
- public
- void test4() throws Exception {
-
- Hashtable inHt = new Hashtable();
- Hashtable witness = new Hashtable();
-
- inHt.put("categoryName", "a.b.c");
- inHt.put("priorityStr", "DEBUG");
- inHt.put("message", "hello");
- Exception e = new ComparableException("test4");
- inHt.put("throwable", e);
-
- witness.put("categoryName", "a.b.c");
- witness.put("priorityStr", "DEBUG");
- witness.put("renderedMessage", "hello");
- witness.put("throwable", e);
-
- byte[] buf = (byte[]) serMethod12a7.invoke(o12a7, new Object[] {inHt});
-
- Hashtable outHt = (Hashtable) deserMethod113.invoke(o113, new Object[] {buf});
-
- //System.out.println("witness"+witness);
- //System.out.println("outHt "+outHt);
-
- assertEquals(witness, outHt);
- }
-
-
- public
- static
- Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new SerializationUT("test1"));
- suite.addTest(new SerializationUT("test2"));
- suite.addTest(new SerializationUT("test3"));
- suite.addTest(new SerializationUT("test4"));
- return suite;
- }
-}
-
-class ComparableException extends Exception {
-
- public ComparableException(String msg) {
- super(msg);
- }
-
- public boolean equals(Object o) {
- System.out.println("ComparableException.equals called.");
- if(!(o instanceof ComparableException))
- return false;
-
- ComparableException r = (ComparableException) o;
-
- if(r.getMessage() == null) {
- if(getMessage() != null)
- return false;
- } else if(!r.getMessage().equals(getMessage())) {
- return false;
- }
- return true;
- }
-}
-
diff --git a/src/java/org/apache/log4j/test/serialization/T/T113.java b/src/java/org/apache/log4j/test/serialization/T/T113.java
deleted file mode 100644
index 746123a884..0000000000
--- a/src/java/org/apache/log4j/test/serialization/T/T113.java
+++ /dev/null
@@ -1,72 +0,0 @@
-
-import java.io.*;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.Priority;
-import org.apache.log4j.spi.LoggingEvent;
-
-import java.util.Hashtable;
-
-
-// String categoryName
-// String ndc
-// boolan ndcLookupRequired
-// String renderedMessage
-// String threadName
-// long timeStamp
-
-// LocationInfo
-// ThrowableInformation ti.
-public class T113 {
-
- public
- byte[] serialize(Hashtable ht) {
- try {
- Category category = Category.getInstance((String) ht.get("categoryName"));
-
-
- LoggingEvent event = new LoggingEvent("org.apache.log4j.Category",
- category,
- Priority.toPriority((String)ht.get("priorityStr")),
- ht.get("message"),
- (Throwable) ht.get("throwable"));
- event.getThreadName();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(event);
- oos.flush();
- return baos.toByteArray();
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public
- Hashtable deserialize(byte[] buf) {
- try {
- System.out.println("deserialize called.");
- ByteArrayInputStream bais = new ByteArrayInputStream(buf);
- ObjectInputStream si = new ObjectInputStream(bais);
- LoggingEvent event = (LoggingEvent) si.readObject();
- System.out.println("Desrialization looks successful.");
-
- return eventToHashtable(event);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- Hashtable eventToHashtable(LoggingEvent event) {
- Hashtable ht = new Hashtable();
- ht.put("categoryName", event.categoryName);
- ht.put("renderedMessage", event.getRenderedMessage());
- ht.put("priorityStr", event.priority.toString());
- ht.put("throwableInfo", event.getThrowableInformation());
- return ht;
- }
-
-}
-
diff --git a/src/java/org/apache/log4j/test/serialization/T/T12.java b/src/java/org/apache/log4j/test/serialization/T/T12.java
deleted file mode 100644
index 9ccf3e1204..0000000000
--- a/src/java/org/apache/log4j/test/serialization/T/T12.java
+++ /dev/null
@@ -1,71 +0,0 @@
-
-import java.io.*;
-
-import org.apache.log4j.*;
-import org.apache.log4j.spi.LoggingEvent;
-
-import java.util.Hashtable;
-
-
-// String categoryName
-// String ndc
-// boolan ndcLookupRequired
-// String renderedMessage
-// String threadName
-// long timeStamp
-
-// LocationInfo
-// ThrowableInformation ti.
-public class T12 {
-
- public
- byte[] serialize(Hashtable ht) {
- try {
- Category category = Category.getInstance((String) ht.get("categoryName"));
-
-
- LoggingEvent event = new LoggingEvent("org.apache.log4j.Category",
- category,
- Level.toLevel((String)ht.get("priorityStr")),
- ht.get("message"),
- (Throwable) ht.get("throwable"));
- event.getThreadName();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(event);
- oos.flush();
- return baos.toByteArray();
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public
- Hashtable deserialize(byte[] buf) {
- try {
- System.out.println("deserialize called.");
- ByteArrayInputStream bais = new ByteArrayInputStream(buf);
- ObjectInputStream si = new ObjectInputStream(bais);
- LoggingEvent event = (LoggingEvent) si.readObject();
- System.out.println("Desrialization looks successful.");
-
- return eventToHashtable(event);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- Hashtable eventToHashtable(LoggingEvent event) {
- Hashtable ht = new Hashtable();
- ht.put("categoryName", event.categoryName);
- ht.put("renderedMessage", event.getRenderedMessage());
- ht.put("priorityStr", event.level.toString());
- ht.put("throwableInfo", event.getThrowableInformation());
- return ht;
- }
-
-}
-
diff --git a/src/java/org/apache/log4j/test/serialization/T/compile.sample.bat b/src/java/org/apache/log4j/test/serialization/T/compile.sample.bat
deleted file mode 100755
index bc1e69762f..0000000000
--- a/src/java/org/apache/log4j/test/serialization/T/compile.sample.bat
+++ /dev/null
@@ -1,15 +0,0 @@
-
-@REM This little script compiles the files T113.java and T12.java with
-@REM different classpaths.
-@REM
-@REM You have to set the classpath to point to rt.jar depending on your
-@REM environment.
-
-set CLASSPATH=.;%JAVA_HOME%\jre\lib\rt.jar;log4j-1.1.3.jar
-
-echo [%CLASSPATH%]
-
-javac T113.java
-
-set CLASSPATH=.;%JAVA_HOME%\jre\lib\rt.jar;log4j-1.2alpha7.jar
-javac -deprecation T12.java
\ No newline at end of file
diff --git a/src/java/org/apache/log4j/test/serialization/T/compile.sample.sh b/src/java/org/apache/log4j/test/serialization/T/compile.sample.sh
deleted file mode 100644
index 1af7a4ee60..0000000000
--- a/src/java/org/apache/log4j/test/serialization/T/compile.sample.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-
-# This little Unix script compiles the files T113.java and T12.java
-# with different classpaths.
-
-# You have to set the classpath to point to rt.jar depending on your
-# environment.
-
-CLASSPATH=".:$JAVA_HOME/jre/lib/rt.jar:log4j-1.1.3.jar"
-javac -deprecation T113.java
-
-CLASSPATH=".:$JAVA_HOME/jre/lib/rt.jar:log4j-1.2alpha7.jar"
-javac -deprecation T12.java
\ No newline at end of file
diff --git a/src/java/org/apache/log4j/test/shallow b/src/java/org/apache/log4j/test/shallow
deleted file mode 100644
index 3b416f4271..0000000000
--- a/src/java/org/apache/log4j/test/shallow
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/bin/bash
-
-# A regression test to check the option reading code and print formats.
-
-# Read the .functions file
-. .functions
-
-A1_PREFIX="log4j.appender.A1"
-A2_PREFIX="log4j.appender.A2"
-
-PORT=12345
-DELAY=5000
-
-# If set, allows to skip tests
-declare -i start=$1
-
-# ----------------------------------------------------------------------
-function testShallow {
- layout=$1
-
- echo -n "Shallow test $TEST - "
- runShallow $LCF
- $PERL filter.pl $TEMP.A1 $OUTPUT.A1 Shallow $layout
- $PERL filter.pl $TEMP.A2 $OUTPUT.A2 Shallow $layout
- if [ $? != 0 ]; then
- echo "The output is not in expected format. See the file [$OUTPUT]."
- exit 1
-fi
- check witness/shallow.A1.$TEST $OUTPUT.A1; echo -n "-"
- check witness/shallow.A2.$TEST $OUTPUT.A2; echo " OK."
-}
-# +============================================
-# Make a config file for the shallow test
-# +============================================
-function makeShallowConfigFile {
- logFile=$1
- rootPriority=$2
- shallowPriority=$3
- layoutClass=$4
- dateFormat=$5
- additivity=$6
-
- echo "$A1_PREFIX=org.apache.log4j.FileAppender" > $LCF
- echo "$A1_PREFIX.Append=false" >> $LCF
- echo "$A1_PREFIX.layout=$layoutClass" >> $LCF
- echo "$A1_PREFIX.layout.DateFormat=$dateFormat" >> $LCF
-
- echo "$A2_PREFIX=org.apache.log4j.FileAppender" >> $LCF
- echo "$A2_PREFIX.append=false" >> $LCF
- echo "$A2_PREFIX.layout=$layoutClass" >> $LCF
- echo "$A2_PREFIX.layout.DateFormat=$dateFormat" >> $LCF
-
-
- echo "$A1_PREFIX.File=$logFile.A1" >> $LCF
- echo "$A2_PREFIX.File=$logFile.A2" >> $LCF
-
- echo "$ROOT_PREFIX=$rootPriority, A1" >> $LCF
- echo "log4j.logger.org.apache.log4j.test.Shallow=$shallowPriority, A2" >> $LCF
-
- if [ -n "$additivity" ]; then
- echo "log4j.additivity.org.apache.log4j.test.Shallow=$additivity" >> $LCF
- fi
-
-}
-# ----------------------------------------------------------------------
-function runShallow() {
- confFile=$1
- #java -Dlog4j.configDebug org.apache.log4j.test.Shallow $confFile
- java org.apache.log4j.test.Shallow $confFile
-}
-# ----------------------------------------------------------------------
-function testSocket {
- layout=$1
- echo -n "Shallow test $TEST - "
- runShallow $LCF
- sleep 8
- $PERL filter.pl $TEMP $OUTPUT Shallow $layout
- check witness/shallow.$TEST $OUTPUT; echo " Test PASSED O.K."
-}
-# ===============================================================
-
-setPERL
-
-declare -i TEST
-
-TEST=1
-if [ $TEST -ge $start ]; then
-
- makeShallowConfigFile $TEMP DEBUG " " $SIMPLE
- testShallow LINE_NUMBER
-fi
-
-
-TEST=2
-if [ $TEST -ge $start ]; then
- makeShallowConfigFile $TEMP INFO DEBUG $SIMPLE xxx true
- testShallow LINE_NUMBER
-fi
-
-TEST=3
-if [ $TEST -ge $start ]; then
- makeShallowConfigFile $TEMP DEBUG " " $TTCC NULL true
- testShallow LINE_NUMBER
-fi
-
-TEST=4
-if [ $TEST -ge $start ]; then
- makeShallowConfigFile $TEMP INFO " " $TTCC RELATIVE
- testShallow RELATIVE
-fi
-
-TEST=5
-if [ $TEST -ge $start ]; then
- makeShallowConfigFile $TEMP DEBUG WARN $TTCC ABSOLUTE
- testShallow ABSOLUTE
-fi
-
-TEST=6
-if [ $TEST -ge $start ]; then
- makeShallowConfigFile $TEMP DEBUG WARN $TTCC DATE
- testShallow DATE
-fi
-
-TEST=7
-if [ $TEST -ge $start ]; then
- makeShallowConfigFile $TEMP DEBUG WARN $TTCC DATE false
- testShallow DATE
-fi
-
-TEST=8
-if [ $TEST -ge $start ]; then
- makeShallowConfigFile $TEMP DEBUG DEBUG $TTCC DATE false
- echo "$A1_PREFIX.Threshold=WARN" >> $LCF
- testShallow DATE
-fi
-
-
diff --git a/src/java/org/apache/log4j/test/stressAsyncAppender.pl b/src/java/org/apache/log4j/test/stressAsyncAppender.pl
deleted file mode 100644
index aeb99a557a..0000000000
--- a/src/java/org/apache/log4j/test/stressAsyncAppender.pl
+++ /dev/null
@@ -1,60 +0,0 @@
-
-# Copyright 2000, Ceki Gulcu. All rights reserved.
-
-package SAA;
-
-$SAA::size = 0;
-$SAA::sizeAvg = 0;
-$n = 0;
-$expected = 0;
-while(abc is the name of the file where
- the XMLLayout ouput goes, then a well-formed XML file would be:
-
-
- <?xml version="1.0" ?>
-
- <!DOCTYPE log4j:eventSet SYSTEM "log4j.dtd" [<!ENTITY data SYSTEM "abc">]>
-
- <log4j:eventSet version="1.2" xmlns:log4j="http://jakarta.apache.org/log4j/">
- &data;
- </log4j:eventSet>
-
-
- version attribute helps components to correctly
- intrepret output generated by XMLLayout. The value of this
- attribute should be "1.1" for output generated by log4j versions
- prior to log4j 1.2 (final release) and "1.2" for relase 1.2 and
- later.
-
- @author Ceki Gülcü
- @since 0.9.0 */
-public class XMLLayout extends Layout {
-
- private final int DEFAULT_SIZE = 256;
- private final int UPPER_LIMIT = 2048;
-
- private StringBuffer buf = new StringBuffer(DEFAULT_SIZE);
- private boolean locationInfo = false;
-
-
- /**
- The LocationInfo option takes a boolean value. By
- default, it is set to false which means there will be no location
- information output by this layout. If the the option is set to
- true, then the file name and line number of the statement
- at the origin of the log statement will be output.
-
- false.
- */
- public
- boolean ignoresThrowable() {
- return false;
- }
-}
diff --git a/src/java/org/apache/log4j/xml/examples/.cvsignore b/src/java/org/apache/log4j/xml/examples/.cvsignore
deleted file mode 100644
index f590ca415d..0000000000
--- a/src/java/org/apache/log4j/xml/examples/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-doc-files
\ No newline at end of file
diff --git a/src/java/org/apache/log4j/xml/examples/ReportParserError.java b/src/java/org/apache/log4j/xml/examples/ReportParserError.java
deleted file mode 100644
index 8846e339f3..0000000000
--- a/src/java/org/apache/log4j/xml/examples/ReportParserError.java
+++ /dev/null
@@ -1,35 +0,0 @@
-
-package org.apache.log4j.xml.examples;
-
-import org.apache.log4j.helpers.LogLog;
-
-/**
-
- This class is needed for validating a log4j.dtd derived XML file.
-
- @author Joe Kesselman
-
- @since 0.8.3
-
- */
-public class ReportParserError implements org.xml.sax.ErrorHandler {
-
- void report(String msg, org.xml.sax.SAXParseException e) {
- LogLog.error(msg+e.getMessage()+ "\n\tat line="+ e.getLineNumber()+
- " col="+e.getColumnNumber()+ " of "+
- "SystemId=\""+e.getSystemId()+
- "\" PublicID = \""+e.getPublicId()+'\"');
- }
-
- public void warning(org.xml.sax.SAXParseException e) {
- report("WARNING: ", e);
- }
-
- public void error(org.xml.sax.SAXParseException e) {
- report("ERROR: ", e);
- }
-
- public void fatalError(org.xml.sax.SAXParseException e) {
- report("FATAL: ", e);
- }
-}
diff --git a/src/java/org/apache/log4j/xml/examples/XMLSample.java b/src/java/org/apache/log4j/xml/examples/XMLSample.java
deleted file mode 100644
index d3ee98cf7a..0000000000
--- a/src/java/org/apache/log4j/xml/examples/XMLSample.java
+++ /dev/null
@@ -1,61 +0,0 @@
-
-package org.apache.log4j.xml.examples;
-
-import org.apache.log4j.xml.DOMConfigurator;
-import org.apache.log4j.Category;
-import java.net.*;
-
-/**
-
- This example code shows how to
- read an XML based configuration file using a DOM parser.
-
-
-
-
-Last modified: Wed Apr 12 22:27:25 MDT 2000
-
-
diff --git a/src/java/org/apache/log4j/xml/test/.cvsignore b/src/java/org/apache/log4j/xml/test/.cvsignore
deleted file mode 100644
index 31efc8c599..0000000000
--- a/src/java/org/apache/log4j/xml/test/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-output*
-temp*
-current.reg
\ No newline at end of file
diff --git a/src/java/org/apache/log4j/xml/test/DOMTest.java b/src/java/org/apache/log4j/xml/test/DOMTest.java
deleted file mode 100644
index 225cfb68e3..0000000000
--- a/src/java/org/apache/log4j/xml/test/DOMTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
-
-package org.apache.log4j.xml.test;
-
-import org.apache.log4j.xml.DOMConfigurator;
-import org.apache.log4j.Category;
-import org.apache.log4j.Priority;
-//import org.apache.log4j.xml.examples.ReportParserError;
-//import org.apache.xerces.parsers.DOMParser;
-//import java.io.FileInputStream;
-//import org.xml.sax.InputSource;
-
-/**
- @author Ceki Gülcü
-*/
-public class DOMTest {
- static Category cat = Category.getInstance(DOMTest.class.getName());
-
-
- public
- static
- void main(String argv[]) {
-
- if(argv.length == 1)
- init(argv[0]);
- else
- Usage("Wrong number of arguments.");
-
- test();
- }
-
- static
- void Usage(String msg) {
- System.err.println(msg);
- System.err.println( "Usage: java " + DOMTest.class.getName() +
- " configFile");
- System.exit(1);
- }
-
- static
- void init(String configFile) {
- DOMConfigurator.configure(configFile);
- }
-
- static
- void test() {
- int i = -1;
- Category root = Category.getRoot();
-
- cat.debug("Message " + ++i);
- root.debug("Message " + i);
-
- cat.info ("Message " + ++i);
- root.info("Message " + i);
-
- cat.warn ("Message " + ++i);
- root.warn("Message " + i);
-
- cat.error("Message " + ++i);
- root.error("Message " + i);
-
- cat.log(Priority.FATAL, "Message " + ++i);
- root.log(Priority.FATAL, "Message " + i);
-
- Exception e = new Exception("Just testing");
- cat.debug("Message " + ++i, e);
- root.debug("Message " + i, e);
-
- cat.error("Message " + ++i, e);
- root.error("Message " + i, e);
-
- Category.shutdown();
- }
-}
diff --git a/src/java/org/apache/log4j/xml/test/testlog.xml b/src/java/org/apache/log4j/xml/test/testlog.xml
deleted file mode 100644
index dd54e58c44..0000000000
--- a/src/java/org/apache/log4j/xml/test/testlog.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-close method.
- @since 0.8.4
- */
+ @since 0.8.4 */
public
void finalize() {
// An appender might be closed then garbage collected. There is no
@@ -191,11 +221,10 @@ boolean isAsSevereAsThreshold(Priority priority) {
/**
- This method performs threshold checks and invokes filters before
- delegating actual logging to the subclasses specific {@link
- AppenderSkeleton#append} method.
-
- */
+ * This method performs threshold checks and invokes filters before
+ * delegating actual logging to the subclasses specific {@link
+ * AppenderSkeleton#append} method.
+ * */
public
synchronized
void doAppend(LoggingEvent event) {
@@ -204,7 +233,7 @@ void doAppend(LoggingEvent event) {
return;
}
- if(!isAsSevereAsThreshold(event.level)) {
+ if(!isAsSevereAsThreshold(event.getLevel())) {
return;
}
@@ -215,7 +244,7 @@ void doAppend(LoggingEvent event) {
switch(f.decide(event)) {
case Filter.DENY: return;
case Filter.ACCEPT: break FILTER_LOOP;
- case Filter.NEUTRAL: f = f.next;
+ case Filter.NEUTRAL: f = f.getNext();
}
}
diff --git a/src/main/java/org/apache/log4j/AsyncAppender.java b/src/main/java/org/apache/log4j/AsyncAppender.java
new file mode 100644
index 0000000000..2a03eb63a6
--- /dev/null
+++ b/src/main/java/org/apache/log4j/AsyncAppender.java
@@ -0,0 +1,593 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Contibutors: Aaron Greenhouse AsyncAppender can only be script
+ * configured using the {@link org.apache.log4j.xml.DOMConfigurator}.
+ *
+ *
+ * @author Ceki Gülcü
+ * @author Curt Arnold
+ * @since 0.9.1
+ */
+public class AsyncAppender extends AppenderSkeleton
+ implements AppenderAttachable {
+ /**
+ * The default buffer size is set to 128 events.
+ */
+ public static final int DEFAULT_BUFFER_SIZE = 128;
+
+ /**
+ * Event buffer, also used as monitor to protect itself and
+ * discardMap from simulatenous modifications.
+ */
+ private final List buffer = new ArrayList();
+
+ /**
+ * Map of DiscardSummary objects keyed by logger name.
+ */
+ private final Map discardMap = new HashMap();
+
+ /**
+ * Buffer size.
+ */
+ private int bufferSize = DEFAULT_BUFFER_SIZE;
+
+ /** Nested appenders. */
+ AppenderAttachableImpl aai;
+
+ /**
+ * Nested appenders.
+ */
+ private final AppenderAttachableImpl appenders;
+
+ /**
+ * Dispatcher.
+ */
+ private final Thread dispatcher;
+
+ /**
+ * Should location info be included in dispatched messages.
+ */
+ private boolean locationInfo = false;
+
+ /**
+ * Does appender block when buffer is full.
+ */
+ private boolean blocking = true;
+
+ /**
+ * Create new instance.
+ */
+ public AsyncAppender() {
+ appenders = new AppenderAttachableImpl();
+
+ //
+ // only set for compatibility
+ aai = appenders;
+
+ dispatcher =
+ new Thread(new Dispatcher(this, buffer, discardMap, appenders));
+
+ // It is the user's responsibility to close appenders before
+ // exiting.
+ dispatcher.setDaemon(true);
+
+ // set the dispatcher priority to lowest possible value
+ // dispatcher.setPriority(Thread.MIN_PRIORITY);
+ dispatcher.setName("Dispatcher-" + dispatcher.getName());
+ dispatcher.start();
+ }
+
+ /**
+ * Add appender.
+ *
+ * @param newAppender appender to add, may not be null.
+ */
+ public void addAppender(final Appender newAppender) {
+ synchronized (appenders) {
+ appenders.addAppender(newAppender);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void append(final LoggingEvent event) {
+ //
+ // if dispatcher thread has died then
+ // append subsequent events synchronously
+ // See bug 23021
+ if ((dispatcher == null) || !dispatcher.isAlive() || (bufferSize <= 0)) {
+ synchronized (appenders) {
+ appenders.appendLoopOnAppenders(event);
+ }
+
+ return;
+ }
+
+ // Set the NDC and thread name for the calling thread as these
+ // LoggingEvent fields were not set at event creation time.
+ event.getNDC();
+ event.getThreadName();
+ // Get a copy of this thread's MDC.
+ event.getMDCCopy();
+ if (locationInfo) {
+ event.getLocationInformation();
+ }
+
+ synchronized (buffer) {
+ while (true) {
+ int previousSize = buffer.size();
+
+ if (previousSize < bufferSize) {
+ buffer.add(event);
+
+ //
+ // if buffer had been empty
+ // signal all threads waiting on buffer
+ // to check their conditions.
+ //
+ if (previousSize == 0) {
+ buffer.notifyAll();
+ }
+
+ break;
+ }
+
+ //
+ // Following code is only reachable if buffer is full
+ //
+ //
+ // if blocking and thread is not already interrupted
+ // and not the dispatcher then
+ // wait for a buffer notification
+ boolean discard = true;
+ if (blocking
+ && !Thread.interrupted()
+ && Thread.currentThread() != dispatcher) {
+ try {
+ buffer.wait();
+ discard = false;
+ } catch (InterruptedException e) {
+ //
+ // reset interrupt status so
+ // calling code can see interrupt on
+ // their next wait or sleep.
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ //
+ // if blocking is false or thread has been interrupted
+ // add event to discard map.
+ //
+ if (discard) {
+ String loggerName = event.getLoggerName();
+ DiscardSummary summary = (DiscardSummary) discardMap.get(loggerName);
+
+ if (summary == null) {
+ summary = new DiscardSummary(event);
+ discardMap.put(loggerName, summary);
+ } else {
+ summary.add(event);
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Close this AsyncAppender by interrupting the dispatcher
+ * thread which will process all pending events before exiting.
+ */
+ public void close() {
+ /**
+ * Set closed flag and notify all threads to check their conditions.
+ * Should result in dispatcher terminating.
+ */
+ synchronized (buffer) {
+ closed = true;
+ buffer.notifyAll();
+ }
+
+ try {
+ dispatcher.join();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ org.apache.log4j.helpers.LogLog.error(
+ "Got an InterruptedException while waiting for the "
+ + "dispatcher to finish.", e);
+ }
+
+ //
+ // close all attached appenders.
+ //
+ synchronized (appenders) {
+ Enumeration iter = appenders.getAllAppenders();
+
+ if (iter != null) {
+ while (iter.hasMoreElements()) {
+ Object next = iter.nextElement();
+
+ if (next instanceof Appender) {
+ ((Appender) next).close();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Get iterator over attached appenders.
+ * @return iterator or null if no attached appenders.
+ */
+ public Enumeration getAllAppenders() {
+ synchronized (appenders) {
+ return appenders.getAllAppenders();
+ }
+ }
+
+ /**
+ * Get appender by name.
+ *
+ * @param name name, may not be null.
+ * @return matching appender or null.
+ */
+ public Appender getAppender(final String name) {
+ synchronized (appenders) {
+ return appenders.getAppender(name);
+ }
+ }
+
+ /**
+ * Gets whether the location of the logging request call
+ * should be captured.
+ *
+ * @return the current value of the LocationInfo option.
+ */
+ public boolean getLocationInfo() {
+ return locationInfo;
+ }
+
+ /**
+ * Determines if specified appender is attached.
+ * @param appender appender.
+ * @return true if attached.
+ */
+ public boolean isAttached(final Appender appender) {
+ synchronized (appenders) {
+ return appenders.isAttached(appender);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean requiresLayout() {
+ return false;
+ }
+
+ /**
+ * Removes and closes all attached appenders.
+ */
+ public void removeAllAppenders() {
+ synchronized (appenders) {
+ appenders.removeAllAppenders();
+ }
+ }
+
+ /**
+ * Removes an appender.
+ * @param appender appender to remove.
+ */
+ public void removeAppender(final Appender appender) {
+ synchronized (appenders) {
+ appenders.removeAppender(appender);
+ }
+ }
+
+ /**
+ * Remove appender by name.
+ * @param name name.
+ */
+ public void removeAppender(final String name) {
+ synchronized (appenders) {
+ appenders.removeAppender(name);
+ }
+ }
+
+ /**
+ * The LocationInfo option takes a boolean value. By default, it is
+ * set to false which means there will be no effort to extract the location
+ * information related to the event. As a result, the event that will be
+ * ultimately logged will likely to contain the wrong location information
+ * (if present in the log format).
+ *
+ *
+ * Location information extraction is comparatively very slow and should be
+ * avoided unless performance is not a concern.
+ *
+ * @param flag true if location information should be extracted.
+ */
+ public void setLocationInfo(final boolean flag) {
+ locationInfo = flag;
+ }
+
+ /**
+ * Sets the number of messages allowed in the event buffer
+ * before the calling thread is blocked (if blocking is true)
+ * or until messages are summarized and discarded. Changing
+ * the size will not affect messages already in the buffer.
+ *
+ * @param size buffer size, must be positive.
+ */
+ public void setBufferSize(final int size) {
+ //
+ // log4j 1.2 would throw exception if size was negative
+ // and deadlock if size was zero.
+ //
+ if (size < 0) {
+ throw new java.lang.NegativeArraySizeException("size");
+ }
+
+ synchronized (buffer) {
+ //
+ // don't let size be zero.
+ //
+ bufferSize = (size < 1) ? 1 : size;
+ buffer.notifyAll();
+ }
+ }
+
+ /**
+ * Gets the current buffer size.
+ * @return the current value of the BufferSize option.
+ */
+ public int getBufferSize() {
+ return bufferSize;
+ }
+
+ /**
+ * Sets whether appender should wait if there is no
+ * space available in the event buffer or immediately return.
+ *
+ * @param value true if appender should wait until available space in buffer.
+ */
+ public void setBlocking(final boolean value) {
+ synchronized (buffer) {
+ blocking = value;
+ buffer.notifyAll();
+ }
+ }
+
+ /**
+ * Gets whether appender should block calling thread when buffer is full.
+ * If false, messages will be counted by logger and a summary
+ * message appended after the contents of the buffer have been appended.
+ *
+ * @return true if calling thread will be blocked when buffer is full.
+ */
+ public boolean getBlocking() {
+ return blocking;
+ }
+
+ /**
+ * Summary of discarded logging events for a logger.
+ */
+ private static final class DiscardSummary {
+ /**
+ * First event of the highest severity.
+ */
+ private LoggingEvent maxEvent;
+
+ /**
+ * Total count of messages discarded.
+ */
+ private int count;
+
+ /**
+ * Create new instance.
+ *
+ * @param event event, may not be null.
+ */
+ public DiscardSummary(final LoggingEvent event) {
+ maxEvent = event;
+ count = 1;
+ }
+
+ /**
+ * Add discarded event to summary.
+ *
+ * @param event event, may not be null.
+ */
+ public void add(final LoggingEvent event) {
+ if (event.getLevel().toInt() > maxEvent.getLevel().toInt()) {
+ maxEvent = event;
+ }
+
+ count++;
+ }
+
+ /**
+ * Create event with summary information.
+ *
+ * @return new event.
+ */
+ public LoggingEvent createEvent() {
+ String msg =
+ MessageFormat.format(
+ "Discarded {0} messages due to full event buffer including: {1}",
+ new Object[] { new Integer(count), maxEvent.getMessage() });
+
+ return new LoggingEvent(
+ "org.apache.log4j.AsyncAppender.DONT_REPORT_LOCATION",
+ Logger.getLogger(maxEvent.getLoggerName()),
+ maxEvent.getLevel(),
+ msg,
+ null);
+ }
+ }
+
+ /**
+ * Event dispatcher.
+ */
+ private static class Dispatcher implements Runnable {
+ /**
+ * Parent AsyncAppender.
+ */
+ private final AsyncAppender parent;
+
+ /**
+ * Event buffer.
+ */
+ private final List buffer;
+
+ /**
+ * Map of DiscardSummary keyed by logger name.
+ */
+ private final Map discardMap;
+
+ /**
+ * Wrapped appenders.
+ */
+ private final AppenderAttachableImpl appenders;
+
+ /**
+ * Create new instance of dispatcher.
+ *
+ * @param parent parent AsyncAppender, may not be null.
+ * @param buffer event buffer, may not be null.
+ * @param discardMap discard map, may not be null.
+ * @param appenders appenders, may not be null.
+ */
+ public Dispatcher(
+ final AsyncAppender parent, final List buffer, final Map discardMap,
+ final AppenderAttachableImpl appenders) {
+
+ this.parent = parent;
+ this.buffer = buffer;
+ this.appenders = appenders;
+ this.discardMap = discardMap;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void run() {
+ boolean isActive = true;
+
+ //
+ // if interrupted (unlikely), end thread
+ //
+ try {
+ //
+ // loop until the AsyncAppender is closed.
+ //
+ while (isActive) {
+ LoggingEvent[] events = null;
+
+ //
+ // extract pending events while synchronized
+ // on buffer
+ //
+ synchronized (buffer) {
+ int bufferSize = buffer.size();
+ isActive = !parent.closed;
+
+ while ((bufferSize == 0) && isActive) {
+ buffer.wait();
+ bufferSize = buffer.size();
+ isActive = !parent.closed;
+ }
+
+ if (bufferSize > 0) {
+ events = new LoggingEvent[bufferSize + discardMap.size()];
+ buffer.toArray(events);
+
+ //
+ // add events due to buffer overflow
+ //
+ int index = bufferSize;
+
+ for (
+ Iterator iter = discardMap.values().iterator();
+ iter.hasNext();) {
+ events[index++] = ((DiscardSummary) iter.next()).createEvent();
+ }
+
+ //
+ // clear buffer and discard map
+ //
+ buffer.clear();
+ discardMap.clear();
+
+ //
+ // allow blocked appends to continue
+ buffer.notifyAll();
+ }
+ }
+
+ //
+ // process events after lock on buffer is released.
+ //
+ if (events != null) {
+ for (int i = 0; i < events.length; i++) {
+ synchronized (appenders) {
+ appenders.appendLoopOnAppenders(events[i]);
+ }
+ }
+ }
+ }
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+}
diff --git a/src/java/org/apache/log4j/BasicConfigurator.java b/src/main/java/org/apache/log4j/BasicConfigurator.java
similarity index 65%
rename from src/java/org/apache/log4j/BasicConfigurator.java
rename to src/main/java/org/apache/log4j/BasicConfigurator.java
index 7817965efc..2d859cf436 100644
--- a/src/java/org/apache/log4j/BasicConfigurator.java
+++ b/src/main/java/org/apache/log4j/BasicConfigurator.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// Contibutors: "Luke Blanshard" Logger is a subclass of Category, i.e. it extends
- Category. In other words, a logger is a category. Thus,
- all operations that can be performed on a category can be performed
- on a logger. Whenever log4j is asked to produce a Category object,
- it will instead produce a Logger object. However, methods that
- previously accepted category objects still continue to accept
- category objects.
-
- Logger is a subclass of Category, i.e. it extends
+ * Category. In other words, a logger is a category. Thus,
+ * all operations that can be performed on a category can be
+ * performed on a logger. Internally, whenever log4j is asked to
+ * produce a Category object, it will instead produce a Logger
+ * object. Log4j 1.2 will never produce Category objects but
+ * only Logger instances. In order to preserve backward
+ * compatibility, methods that previously accepted category objects
+ * still continue to accept category objects.
+ *
+ *
- // Deprecated form:
- Category cat = Category.getInstance("foo.bar")
-
- // Preferred form for retrieving loggers:
- Logger logger = Logger.getLogger("foo.bar")
+ // Deprecated form:
+ Category cat = Category.getInstance("foo.bar")
+
+ // Preferred form for retrieving loggers:
+ Logger logger = Logger.getLogger("foo.bar")
-
- Category class. Whenever possible,
- please avoid referring to it or using it.
-
- Category class. Whenever possible,
+ * please avoid referring to it or using it.
+ *
+ * name
- parameter. If the named category already exists, then the
- existing instance will be reutrned. Otherwise, a new instance is
- created.
-
- By default, categories do not have a set level but inherit
- it from the hierarchy. This is one of the central features of
- log4j.
-
- Deprecated Please use {@link Logger#getLogger(String)}
- instead.
-
- @param name The name of the category to retrieve. */
+ * @deprecated Make sure to use {@link Logger#getLogger(String)} instead.
+ */
public
static
Category getInstance(String name) {
- nooptimize++;
return LogManager.getLogger(name);
}
/**
- Shorthand for getInstance(clazz.getName()).
-
- @param clazz The name of clazz will be used as the
- name of the category to retrieve. See {@link
- #getInstance(String)} for more detailed information.
-
- Deprecated Please use {@link Logger#getLogger(Class)} instead.
-
- @since 1.0 */
+ * @deprecated Please make sure to use {@link Logger#getLogger(Class)} instead.
+ */
public
static
Category getInstance(Class clazz) {
- nooptimize++;
return LogManager.getLogger(clazz);
}
@@ -581,16 +576,7 @@ Level getPriority() {
/**
- Return the root of the default category hierrachy.
-
- System.out or
+ * System.err using a layout specified by the user. The
+ * default target is System.out.
+ *
+ * @author Ceki Gülcü
+ * @author Curt Arnold
+ * @since 1.1 */
+public class ConsoleAppender extends WriterAppender {
+
+ public static final String SYSTEM_OUT = "System.out";
+ public static final String SYSTEM_ERR = "System.err";
+
+ protected String target = SYSTEM_OUT;
+
+ /**
+ * Determines if the appender honors reassignments of System.out
+ * or System.err made after configuration.
+ */
+ private boolean follow = false;
+
+ /**
+ * Constructs an unconfigured appender.
+ */
+ public ConsoleAppender() {
+ }
+
+ /**
+ * Creates a configured appender.
+ *
+ * @param layout layout, may not be null.
+ */
+ public ConsoleAppender(Layout layout) {
+ this(layout, SYSTEM_OUT);
+ }
+
+ /**
+ * Creates a configured appender.
+ * @param layout layout, may not be null.
+ * @param target target, either "System.err" or "System.out".
+ */
+ public ConsoleAppender(Layout layout, String target) {
+ setLayout(layout);
+ setTarget(target);
+ activateOptions();
+ }
+
+ /**
+ * Sets the value of the Target option. Recognized values
+ * are "System.out" and "System.err". Any other value will be
+ * ignored.
+ * */
+ public
+ void setTarget(String value) {
+ String v = value.trim();
+
+ if (SYSTEM_OUT.equalsIgnoreCase(v)) {
+ target = SYSTEM_OUT;
+ } else if (SYSTEM_ERR.equalsIgnoreCase(v)) {
+ target = SYSTEM_ERR;
+ } else {
+ targetWarn(value);
+ }
+ }
+
+ /**
+ * Returns the current value of the Target property. The
+ * default value of the option is "System.out".
+ *
+ * See also {@link #setTarget}.
+ * */
+ public
+ String getTarget() {
+ return target;
+ }
+
+ /**
+ * Sets whether the appender honors reassignments of System.out
+ * or System.err made after configuration.
+ * @param newValue if true, appender will use value of System.out or
+ * System.err in force at the time when logging events are appended.
+ * @since 1.2.13
+ */
+ public final void setFollow(final boolean newValue) {
+ follow = newValue;
+ }
+
+ /**
+ * Gets whether the appender honors reassignments of System.out
+ * or System.err made after configuration.
+ * @return true if appender will use value of System.out or
+ * System.err in force at the time when logging events are appended.
+ * @since 1.2.13
+ */
+ public final boolean getFollow() {
+ return follow;
+ }
+
+ void targetWarn(String val) {
+ LogLog.warn("["+val+"] should be System.out or System.err.");
+ LogLog.warn("Using previously set target, System.out by default.");
+ }
+
+ /**
+ * Prepares the appender for use.
+ */
+ public void activateOptions() {
+ if (follow) {
+ if (target.equals(SYSTEM_ERR)) {
+ setWriter(createWriter(new SystemErrStream()));
+ } else {
+ setWriter(createWriter(new SystemOutStream()));
+ }
+ } else {
+ if (target.equals(SYSTEM_ERR)) {
+ setWriter(createWriter(System.err));
+ } else {
+ setWriter(createWriter(System.out));
+ }
+ }
+
+ super.activateOptions();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected
+ final
+ void closeWriter() {
+ if (follow) {
+ super.closeWriter();
+ }
+ }
+
+
+ /**
+ * An implementation of OutputStream that redirects to the
+ * current System.err.
+ *
+ */
+ private static class SystemErrStream extends OutputStream {
+ public SystemErrStream() {
+ }
+
+ public void close() {
+ }
+
+ public void flush() {
+ System.err.flush();
+ }
+
+ public void write(final byte[] b) throws IOException {
+ System.err.write(b);
+ }
+
+ public void write(final byte[] b, final int off, final int len)
+ throws IOException {
+ System.err.write(b, off, len);
+ }
+
+ public void write(final int b) throws IOException {
+ System.err.write(b);
+ }
+ }
+
+ /**
+ * An implementation of OutputStream that redirects to the
+ * current System.out.
+ *
+ */
+ private static class SystemOutStream extends OutputStream {
+ public SystemOutStream() {
+ }
+
+ public void close() {
+ }
+
+ public void flush() {
+ System.out.flush();
+ }
+
+ public void write(final byte[] b) throws IOException {
+ System.out.write(b);
+ }
+
+ public void write(final byte[] b, final int off, final int len)
+ throws IOException {
+ System.out.write(b, off, len);
+ }
+
+ public void write(final int b) throws IOException {
+ System.out.write(b);
+ }
+ }
+
+}
diff --git a/src/java/org/apache/log4j/DailyRollingFileAppender.java b/src/main/java/org/apache/log4j/DailyRollingFileAppender.java
similarity index 74%
rename from src/java/org/apache/log4j/DailyRollingFileAppender.java
rename to src/main/java/org/apache/log4j/DailyRollingFileAppender.java
index c90a209481..00a4ee5032 100644
--- a/src/java/org/apache/log4j/DailyRollingFileAppender.java
+++ b/src/main/java/org/apache/log4j/DailyRollingFileAppender.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
@@ -52,11 +62,10 @@
'.'yyyy-MM
Rollover at the beginning of each month
- Assuming the first day of the week is Sunday, at Sunday 00:00,
- March 25th, 2001, /foo/bar.log will be copied to
- /foo/bar.log.2001-03. Logging for the month of April
- will be output to /foo/bar.log until it rolls over
- at the beginning of May.
+ At midnight of May 31st, 2002 /foo/bar.log will be
+ copied to /foo/bar.log.2002-05. Logging for the month
+ of June will be output to /foo/bar.log until it is
+ also rolled over the next month.
'.'yyyy-ww
@@ -64,18 +73,19 @@
Rollover at the first day of each week. The first day of the
week depends on the locale.
- At midnight, on March 31st, 2001, /foo/bar.log
- will be copied to /foo/bar.log.2001-08. Logging for
- the 9th week of 2001 will be output to /foo/bar.log
- until it is rolled over the next week.
+ Assuming the first day of the week is Sunday, on Saturday
+ midnight, June 9th 2002, the file /foo/bar.log will be
+ copied to /foo/bar.log.2002-23. Logging for the 24th week
+ of 2002 will be output to /foo/bar.log until it is
+ rolled over the next week.
'.'yyyy-MM-dd
Rollover at midnight each day.
- At midnight, on March 9th, 2001, /foo/bar.log will
- be copied to /foo/bar.log.2001-03-08. Logging for the
+ At midnight, on March 8th, 2002, /foo/bar.log will
+ be copied to /foo/bar.log.2002-03-08. Logging for the
9th day of March will be output to /foo/bar.log until
it is rolled over the next day.
@@ -84,19 +94,19 @@
Rollover at midnight and midday of each day.
- At noon, on March 9th, 2001, /foo/bar.log will be
- copied to /foo/bar.log.2001-03-09-AM. Logging for the
+ At noon, on March 9th, 2002, /foo/bar.log will be
+ copied to /foo/bar.log.2002-03-09-AM. Logging for the
afternoon of the 9th will be output to /foo/bar.log
- until it is rolled over the next morning, i.e at midnight 00:00.
+ until it is rolled over at midnight.
'.'yyyy-MM-dd-HH
Rollover at the top of every hour.
- At approximately 11:00,000, on March 9th, 2001,
+ At approximately 11:00.000 o'clock on March 9th, 2002,
/foo/bar.log will be copied to
- /foo/bar.log.2001-03-09-10. Logging for the 11th hour
+ /foo/bar.log.2002-03-09-10. Logging for the 11th hour
of the 9th of March will be output to /foo/bar.log
until it is rolled over at the beginning of the next hour.
@@ -143,13 +153,19 @@ public class DailyRollingFileAppender extends FileAppender {
private String datePattern = "'.'yyyy-MM-dd";
/**
- The actual formatted filename that is currently being written to.
+ The log file will be renamed to the value of the
+ scheduledFilename variable when the next interval is entered. For
+ example, if the rollover period is one hour, the log file will be
+ renamed to the value of "scheduledFilename" at the beginning of
+ the next hour.
+
+ The precise time when a rollover occurs depends on logging
+ activity.
*/
private String scheduledFilename;
/**
- The timestamp when we shall next recompute the filename.
- */
+ The next time we estimate a rollover should occur. */
private long nextCheck = System.currentTimeMillis () - 1;
Date now = new Date();
@@ -160,14 +176,13 @@ public class DailyRollingFileAppender extends FileAppender {
int checkPeriod = TOP_OF_TROUBLE;
-
+ // The gmtTimeZone is used only in computeCheckPeriod() method.
static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");
/**
The default constructor does nothing. */
- public
- DailyRollingFileAppender() {
+ public DailyRollingFileAppender() {
}
/**
@@ -188,19 +203,16 @@ public DailyRollingFileAppender (Layout layout, String filename,
expected by {@link SimpleDateFormat}. This options determines the
rollover schedule.
*/
- public
- void setDatePattern(String pattern) {
+ public void setDatePattern(String pattern) {
datePattern = pattern;
}
/** Returns the value of the DatePattern option. */
- public
- String getDatePattern() {
+ public String getDatePattern() {
return datePattern;
}
- public
- void activateOptions() {
+ public void activateOptions() {
super.activateOptions();
if(datePattern != null && fileName != null) {
now.setTime(System.currentTimeMillis());
@@ -212,8 +224,8 @@ void activateOptions() {
scheduledFilename = fileName+sdf.format(new Date(file.lastModified()));
} else {
- LogLog.error("Either Filename or DatePattern options are not set for ["+
- name+"].");
+ LogLog.error("Either File or DatePattern options are not set for appender ["
+ +name+"].");
}
}
@@ -290,6 +302,9 @@ void rollOver() throws IOException {
}
String datedFilename = fileName+sdf.format(now);
+ // It is too early to roll over because we are still within the
+ // bounds of the current interval. Rollover will occur once the
+ // next interval is reached.
if (scheduledFilename.equals(datedFilename)) {
return;
}
@@ -303,8 +318,12 @@ void rollOver() throws IOException {
}
File file = new File(fileName);
- file.renameTo(target);
- LogLog.debug(fileName +" -> "+ scheduledFilename);
+ boolean result = file.renameTo(target);
+ if(result) {
+ LogLog.debug(fileName +" -> "+ scheduledFilename);
+ } else {
+ LogLog.error("Failed to rename ["+fileName+"] to ["+scheduledFilename+"].");
+ }
try {
// This will also close the file. This is OK since multiple
@@ -318,17 +337,14 @@ void rollOver() throws IOException {
}
/**
- This method differentiates DailyRollingFileAppender from its
- super class.
-
- java.io.Writer and console appending
- has been deprecated and then removed. See the replacement
- solutions: {@link WriterAppender} and {@link ConsoleAppender}.
-
-
- @author Ceki Gülcü */
+ * FileAppender appends log events to a file.
+ *
+ * java.io.Writer and console appending
+ * has been deprecated and then removed. See the replacement
+ * solutions: {@link WriterAppender} and {@link ConsoleAppender}.
+ *
+ * @author Ceki Gülcü
+ * */
public class FileAppender extends WriterAppender {
- /** Append to or truncate the file? The default value for this
- variable is true, meaning that by default a
- FileAppender will append to an existing file and
- not truncate it.
-
- true, meaning that by default a
+ * FileAppender will append to an existing file and not
+ * truncate it.
+ *
+ * " + Layout.LINE_SEP);
sbuf.append("
@@ -361,10 +370,10 @@ reached. The default is to pad on the left (right justify) but you
");
- sbuf.append(event.timeStamp - event.getStartTime());
+ sbuf.append(event.timeStamp - LoggingEvent.getStartTime());
sbuf.append(" " + Layout.LINE_SEP);
- sbuf.append("");
- sbuf.append(Transform.escapeTags(event.getThreadName()));
+ String escapedThread = Transform.escapeTags(event.getThreadName());
+ sbuf.append(" ");
+ sbuf.append(escapedThread);
sbuf.append(" " + Layout.LINE_SEP);
sbuf.append("");
- if (event.level.equals(Level.DEBUG)) {
+ if (event.getLevel().equals(Level.DEBUG)) {
sbuf.append("");
- sbuf.append(event.level);
+ sbuf.append(Transform.escapeTags(String.valueOf(event.getLevel())));
sbuf.append("");
}
- else if(event.level.isGreaterOrEqual(Level.WARN)) {
+ else if(event.getLevel().isGreaterOrEqual(Level.WARN)) {
sbuf.append("");
- sbuf.append(event.level);
+ sbuf.append(Transform.escapeTags(String.valueOf(event.getLevel())));
sbuf.append("");
} else {
- sbuf.append(event.level);
+ sbuf.append(Transform.escapeTags(String.valueOf(event.getLevel())));
}
sbuf.append(" " + Layout.LINE_SEP);
- sbuf.append("");
- sbuf.append(Transform.escapeTags(event.categoryName));
+ String escapedLogger = Transform.escapeTags(event.getLoggerName());
+ sbuf.append(" ");
+ sbuf.append(escapedLogger);
sbuf.append(" " + Layout.LINE_SEP);
if(locationInfo) {
diff --git a/src/java/org/apache/log4j/Hierarchy.java b/src/main/java/org/apache/log4j/Hierarchy.java
similarity index 94%
rename from src/java/org/apache/log4j/Hierarchy.java
rename to src/main/java/org/apache/log4j/Hierarchy.java
index 5b605c1d45..2c5c0dd408 100644
--- a/src/java/org/apache/log4j/Hierarchy.java
+++ b/src/main/java/org/apache/log4j/Hierarchy.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// WARNING This class MUST not have references to the Category or
// WARNING RootCategory classes in its static initiliazation neither
diff --git a/src/java/org/apache/log4j/Layout.java b/src/main/java/org/apache/log4j/Layout.java
similarity index 67%
rename from src/java/org/apache/log4j/Layout.java
rename to src/main/java/org/apache/log4j/Layout.java
index b4b92c5e78..798dd8ec0a 100644
--- a/src/java/org/apache/log4j/Layout.java
+++ b/src/main/java/org/apache/log4j/Layout.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j;
diff --git a/src/java/org/apache/log4j/Level.java b/src/main/java/org/apache/log4j/Level.java
similarity index 54%
rename from src/java/org/apache/log4j/Level.java
rename to src/main/java/org/apache/log4j/Level.java
index 4bf4b00c9c..502886242a 100644
--- a/src/java/org/apache/log4j/Level.java
+++ b/src/main/java/org/apache/log4j/Level.java
@@ -1,15 +1,29 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
// Contributors: Kitching Simon OFF has the highest possible rank and is
@@ -59,11 +78,24 @@ public class Level extends Priority {
application. */
final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
+ /**
+ * The TRACE Level designates finer-grained
+ * informational events than the DEBUGALL has the lowest possible rank and is intended to
turn on all logging. */
final static public Level ALL = new Level(ALL_INT, "ALL", 7);
+ /**
+ * Serialization version id.
+ */
+ static final long serialVersionUID = 3491141966387921974L;
+
/**
Instantiate a Level object.
*/
@@ -109,6 +141,7 @@ Level toLevel(int val, Level defaultLevel) {
case ERROR_INT: return Level.ERROR;
case FATAL_INT: return Level.FATAL;
case OFF_INT: return OFF;
+ case TRACE_INT: return Level.TRACE;
default: return defaultLevel;
}
}
@@ -128,12 +161,64 @@ Level toLevel(String sArg, Level defaultLevel) {
if(s.equals("ALL")) return Level.ALL;
if(s.equals("DEBUG")) return Level.DEBUG;
- //if(s.equals("FINE")) return Level.FINE;
if(s.equals("INFO")) return Level.INFO;
if(s.equals("WARN")) return Level.WARN;
if(s.equals("ERROR")) return Level.ERROR;
if(s.equals("FATAL")) return Level.FATAL;
if(s.equals("OFF")) return Level.OFF;
+ if(s.equals("TRACE")) return Level.TRACE;
+ //
+ // For Turkish i problem, see bug 40937
+ //
+ if(s.equals("\u0130NFO")) return Level.INFO;
return defaultLevel;
}
+
+ /**
+ * Custom deserialization of Level.
+ * @param s serialization stream.
+ * @throws IOException if IO exception.
+ * @throws ClassNotFoundException if class not found.
+ */
+ private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
+ s.defaultReadObject();
+ level = s.readInt();
+ syslogEquivalent = s.readInt();
+ levelStr = s.readUTF();
+ if (levelStr == null) {
+ levelStr = "";
+ }
+ }
+
+ /**
+ * Serialize level.
+ * @param s serialization stream.
+ * @throws IOException if exception during serialization.
+ */
+ private void writeObject(final ObjectOutputStream s) throws IOException {
+ s.defaultWriteObject();
+ s.writeInt(level);
+ s.writeInt(syslogEquivalent);
+ s.writeUTF(levelStr);
+ }
+
+ /**
+ * Resolved deserialized level to one of the stock instances.
+ * May be overriden in classes derived from Level.
+ * @return resolved object.
+ * @throws ObjectStreamException if exception during resolution.
+ */
+ private Object readResolve() throws ObjectStreamException {
+ //
+ // if the deserizalized object is exactly an instance of Level
+ //
+ if (getClass() == Level.class) {
+ return toLevel(level);
+ }
+ //
+ // extension of Level can't substitute stock item
+ //
+ return this;
+ }
+
}
diff --git a/src/java/org/apache/log4j/LogManager.java b/src/main/java/org/apache/log4j/LogManager.java
similarity index 57%
rename from src/java/org/apache/log4j/LogManager.java
rename to src/main/java/org/apache/log4j/LogManager.java
index 0189b8a4b8..9f129e7190 100644
--- a/src/java/org/apache/log4j/LogManager.java
+++ b/src/main/java/org/apache/log4j/LogManager.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j;
@@ -11,7 +21,7 @@
import org.apache.log4j.spi.LoggerFactory;
import org.apache.log4j.spi.RepositorySelector;
import org.apache.log4j.spi.DefaultRepositorySelector;
-import org.apache.log4j.spi.RootCategory;
+import org.apache.log4j.spi.RootLogger;
import org.apache.log4j.helpers.Loader;
import org.apache.log4j.helpers.OptionConverter;
import org.apache.log4j.helpers.LogLog;
@@ -23,84 +33,40 @@
import java.util.Enumeration;
/**
- Use the LogManager to retreive instances of {@link Logger}.
-
- @author Ceki Gülcü
-*/
+ * Use the LogManager class to retreive {@link Logger}
+ * instances or to operate on the current {@link
+ * LoggerRepository}. When the LogManager class is loaded
+ * into memory the default initalzation procedure is inititated. The
+ * default intialization procedure is described in the short log4j manual.
+ *
+ * @author Ceki Gülcü */
public class LogManager {
/**
- This string constant is set to log4j.properties the name
- of the file that will be searched by default in classpath. If the
- file can be found, then it is fed to the {@link
- PropertyConfigurator}.
-
- See also {@link #DEFAULT_CONFIGURATION_KEY} for a more general
- alternative.
-
- DEBUG
+ enabled by comparing the level of this category with the {@link
+ Level#DEBUG DEBUG} level. If this category is
+ DEBUG enabled, then it converts the message object
+ (passed as parameter) to a string by invoking the appropriate
+ {@link org.apache.log4j.or.ObjectRenderer}. It then proceeds to call all the
+ registered appenders in this category and also higher in the
+ hierarchy depending on the value of the additivity flag.
+
+ Throwable but no
+ stack trace. To print a stack trace use the {@link #debug(Object,
+ Throwable)} form instead.
+
+ @param message the message object to log. */
+ //public
+ //void fine(Object message) {
+ // if(repository.isDisabled(Level.DEBUG_INT))
+ // return;
+ // if(Level.DEBUG.isGreaterOrEqual(this.getChainedLevel())) {
+ // forcedLog(FQCN, Level.DEBUG, message, null);
+ // }
+ //}
+
+
+ /**
+ Log a message object with the FINE level including
+ the stack trace of the {@link Throwable} t passed as
+ parameter.
+
+ name parameter. If the named logger already exists,
+ * then the existing instance will be returned. Otherwise, a new
+ * instance is created.
+ *
+ * getLogger(clazz.getName()).
+ *
+ * @param clazz The name of clazz will be used as the
+ * name of the logger to retrieve. See {@link #getLogger(String)}
+ * for more detailed information.
+ */
+ static
+ public
+ Logger getLogger(Class clazz) {
+ return LogManager.getLogger(clazz.getName());
+ }
+
+
+ /**
+ * Return the root logger for the current logger repository.
+ * Logger.getLogger("root") does not retrieve the root
+ * logger but a logger just under root named "root".
+ * factory parameter.
+
+ TRACE level including the
+ * stack trace of the {@link Throwable}t passed as parameter.
+ *
+ * true if this category is enabled for level
+ * TRACE, false otherwise.
+ */
+ public boolean isTraceEnabled() {
+ if (repository.isDisabled(Level.TRACE_INT)) {
+ return false;
+ }
+
+ return Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel());
+ }
+
+}
diff --git a/src/java/org/apache/log4j/MDC.java b/src/main/java/org/apache/log4j/MDC.java
similarity index 70%
rename from src/java/org/apache/log4j/MDC.java
rename to src/main/java/org/apache/log4j/MDC.java
index 002b3994de..c770670b82 100644
--- a/src/java/org/apache/log4j/MDC.java
+++ b/src/main/java/org/apache/log4j/MDC.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j;
@@ -88,11 +97,10 @@ void remove(String key) {
/**
- Get the current thread's MDC as a hashtable.
- */
- public
- static
- Hashtable getContext() {
+ * Get the current thread's MDC as a hashtable. This method is
+ * intended to be used internally.
+ * */
+ public static Hashtable getContext() {
return mdc.getContext0();
}
@@ -104,8 +112,8 @@ void put0(String key, Object o) {
} else {
Hashtable ht = (Hashtable) ((ThreadLocalMap)tlm).get();
if(ht == null) {
- ht = new Hashtable(HT_SIZE);
- ((ThreadLocalMap)tlm).set(ht);
+ ht = new Hashtable(HT_SIZE);
+ ((ThreadLocalMap)tlm).set(ht);
}
ht.put(key, o);
}
@@ -117,10 +125,10 @@ Object get0(String key) {
return null;
} else {
Hashtable ht = (Hashtable) ((ThreadLocalMap)tlm).get();
- if(ht != null) {
- return ht.get(key);
+ if(ht != null && key != null) {
+ return ht.get(key);
} else {
- return null;
+ return null;
}
}
}
@@ -130,7 +138,7 @@ void remove0(String key) {
if(!java1) {
Hashtable ht = (Hashtable) ((ThreadLocalMap)tlm).get();
if(ht != null) {
- ht.remove(key);
+ ht.remove(key);
}
}
}
diff --git a/src/java/org/apache/log4j/NDC.java b/src/main/java/org/apache/log4j/NDC.java
similarity index 86%
rename from src/java/org/apache/log4j/NDC.java
rename to src/main/java/org/apache/log4j/NDC.java
index aa4461518b..703cfc5b60 100644
--- a/src/java/org/apache/log4j/NDC.java
+++ b/src/main/java/org/apache/log4j/NDC.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
// Contributors: Dan Milstein
@@ -116,6 +125,17 @@ public class NDC {
// No instances allowed.
private NDC() {}
+
+ /**
+ * Get NDC stack for current thread.
+ * @return NDC stack for current thread.
+ */
+ private static Stack getCurrentStack() {
+ if (ht != null) {
+ return (Stack) ht.get(Thread.currentThread());
+ }
+ return null;
+ }
/**
@@ -130,7 +150,7 @@ private NDC() {}
public
static
void clear() {
- Stack stack = (Stack) ht.get(Thread.currentThread());
+ Stack stack = getCurrentStack();
if(stack != null)
stack.setSize(0);
}
@@ -153,11 +173,10 @@ given thread can supply the stack (i.e. diagnostic context) to a
public
static
Stack cloneStack() {
- Object o = ht.get(Thread.currentThread());
- if(o == null)
+ Stack stack = getCurrentStack();
+ if(stack == null)
return null;
else {
- Stack stack = (Stack) o;
return (Stack) stack.clone();
}
}
@@ -192,12 +211,13 @@ void inherit(Stack stack) {
/**
- Used when printing the diagnostic context.
+ Never use this method directly, use the {@link
+ org.apache.log4j.spi.LoggingEvent#getNDC} method instead.
*/
static
public
String get() {
- Stack s = (Stack) ht.get(Thread.currentThread());
+ Stack s = getCurrentStack();
if(s != null && !s.isEmpty())
return ((DiagnosticContext) s.peek()).fullMessage;
else
@@ -205,15 +225,15 @@ String get() {
}
/**
- Get the current nesting depth of this diagnostic context.
-
- @see #setMaxDepth
- @since 0.7.5
+ * Get the current nesting depth of this diagnostic context.
+ *
+ * @see #setMaxDepth
+ * @since 0.7.5
*/
public
static
int getDepth() {
- Stack stack = (Stack) ht.get(Thread.currentThread());
+ Stack stack = getCurrentStack();
if(stack == null)
return 0;
else
@@ -223,6 +243,7 @@ int getDepth() {
private
static
void lazyRemove() {
+ if (ht == null) return;
// The synchronization on ht is necessary to prevent JDK 1.2.x from
// throwing ConcurrentModificationExceptions at us. This sucks BIG-TIME.
@@ -239,13 +260,13 @@ void lazyRemove() {
int misses = 0;
v = new Vector();
- Enumeration enum = ht.keys();
+ Enumeration enumeration = ht.keys();
// We give up after 4 straigt missses. That is 4 consecutive
// inspected threads in 'ht' that turn out to be alive.
// The higher the proportion on dead threads in ht, the higher the
// chances of removal.
- while(enum.hasMoreElements() && (misses <= 4)) {
- Thread t = (Thread) enum.nextElement();
+ while(enumeration.hasMoreElements() && (misses <= 4)) {
+ Thread t = (Thread) enumeration.nextElement();
if(t.isAlive()) {
misses++;
} else {
@@ -277,8 +298,7 @@ void lazyRemove() {
public
static
String pop() {
- Thread key = Thread.currentThread();
- Stack stack = (Stack) ht.get(key);
+ Stack stack = getCurrentStack();
if(stack != null && !stack.isEmpty())
return ((DiagnosticContext) stack.pop()).message;
else
@@ -298,8 +318,7 @@ String pop() {
public
static
String peek() {
- Thread key = Thread.currentThread();
- Stack stack = (Stack) ht.get(key);
+ Stack stack = getCurrentStack();
if(stack != null && !stack.isEmpty())
return ((DiagnosticContext) stack.peek()).message;
else
@@ -316,12 +335,12 @@ String peek() {
public
static
void push(String message) {
- Thread key = Thread.currentThread();
- Stack stack = (Stack) ht.get(key);
+ Stack stack = getCurrentStack();
if(stack == null) {
DiagnosticContext dc = new DiagnosticContext(message, null);
stack = new Stack();
+ Thread key = Thread.currentThread();
ht.put(key, stack);
stack.push(dc);
} else if (stack.isEmpty()) {
@@ -391,7 +410,7 @@ void foo() {
static
public
void setMaxDepth(int maxDepth) {
- Stack stack = (Stack) ht.get(Thread.currentThread());
+ Stack stack = getCurrentStack();
if(stack != null && maxDepth < stack.size())
stack.setSize(maxDepth);
}
diff --git a/src/java/org/apache/log4j/PatternLayout.java b/src/main/java/org/apache/log4j/PatternLayout.java
similarity index 93%
rename from src/java/org/apache/log4j/PatternLayout.java
rename to src/main/java/org/apache/log4j/PatternLayout.java
index a276f257e3..3cfa286568 100644
--- a/src/java/org/apache/log4j/PatternLayout.java
+++ b/src/main/java/org/apache/log4j/PatternLayout.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j;
@@ -222,8 +231,8 @@ number of right most components of the class name will be
r
- Used to output the number of milliseconds elapsed since the start
- of the application until the creation of the logging event.
+ Used to output the number of milliseconds elapsed from the construction
+ of the layout until the creation of the logging event.
-
FATAL level designates very severe error
- events that will presumably lead the application to abort.
+ * @deprecated Use {@link Level#FATAL} instead.
*/
final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
/**
- The ERROR level designates error events that
- might still allow the application to continue running. */
+ * @deprecated Use {@link Level#ERROR} instead.
+ */
final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
/**
- The WARN level designates potentially harmful situations.
- */
+ * @deprecated Use {@link Level#WARN} instead.
+ */
final static public Priority WARN = new Level(WARN_INT, "WARN", 4);
/**
- The INFO level designates informational messages
- that highlight the progress of the application at coarse-grained
- level. */
+ * @deprecated Use {@link Level#INFO} instead.
+ */
final static public Priority INFO = new Level(INFO_INT, "INFO", 6);
/**
- The DEBUG priority designates fine-grained
- informational events that are most useful to debug an
- application. */
+ * @deprecated Use {@link Level#DEBUG} instead.
+ */
final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
-
+
+ /**
+ * Default constructor for deserialization.
+ */
+ protected Priority() {
+ level = DEBUG_INT;
+ levelStr = "DEBUG";
+ syslogEquivalent = 7;
+ }
+
/**
Instantiate a level object.
*/
@@ -141,12 +156,7 @@ int toInt() {
}
/**
- Convert the string passed as argument to a priority. If the
- conversion fails, then this method returns {@link #DEBUG}.
-
- @deprecated Please use the {@link Level#toLevel(String)} method instead.}
-
-
+ * @deprecated Please use the {@link Level#toLevel(String)} method instead.
*/
public
static
@@ -155,10 +165,8 @@ Priority toPriority(String sArg) {
}
/**
- Convert an integer passed as argument to a priority. If the
- conversion fails, then this method returns {@link #DEBUG}.
-
- */
+ * @deprecated Please use the {@link Level#toLevel(int)} method instead.
+ */
public
static
Priority toPriority(int val) {
@@ -166,8 +174,7 @@ Priority toPriority(int val) {
}
/**
- Convert an integer passed as argument to a priority. If the
- conversion fails, then this method returns the specified default.
+ * @deprecated Please use the {@link Level#toLevel(int, Level)} method instead.
*/
public
static
@@ -176,10 +183,8 @@ Priority toPriority(int val, Priority defaultPriority) {
}
/**
- Convert the string passed as argument to a priority. If the
- conversion fails, then this method returns the value of
- defaultPriority.
- */
+ * @deprecated Please use the {@link Level#toLevel(String, Level)} method instead.
+ */
public
static
Priority toPriority(String sArg, Priority defaultPriority) {
diff --git a/src/java/org/apache/log4j/PropertyConfigurator.java b/src/main/java/org/apache/log4j/PropertyConfigurator.java
similarity index 90%
rename from src/java/org/apache/log4j/PropertyConfigurator.java
rename to src/main/java/org/apache/log4j/PropertyConfigurator.java
index c15d438f26..05834b0e4c 100644
--- a/src/java/org/apache/log4j/PropertyConfigurator.java
+++ b/src/main/java/org/apache/log4j/PropertyConfigurator.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// Contibutors: "Luke Blanshard" doConfigure.
@@ -118,7 +126,7 @@ public class PropertyConfigurator implements Configurator {
ALL.
@@ -175,7 +183,7 @@ public class PropertyConfigurator implements Configurator {
- log4j.logger.logger_name=[level|INHERITED], appenderName, appenderName, ...
+ log4j.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ...
encoding variable is set to null by
default which results in the utilization of the system's default
encoding. */
@@ -194,17 +204,18 @@ void close() {
writeFooter();
reset();
}
+
/**
- Close the underlying {@link java.io.Writer}.
- */
- protected
- void closeWriter() {
+ * Close the underlying {@link java.io.Writer}.
+ * */
+ protected void closeWriter() {
if(qw != null) {
try {
qw.close();
} catch(IOException e) {
- LogLog.error("Could not close " + qw, e); // do need to invoke an error handler
- // at this late stage
+ // There is do need to invoke an error handler at this late
+ // stage.
+ LogLog.error("Could not close " + qw, e);
}
}
}
@@ -234,13 +245,11 @@ OutputStreamWriter createWriter(OutputStream os) {
return retval;
}
- public
- String getEncoding() {
+ public String getEncoding() {
return encoding;
}
- public
- void setEncoding(String value) {
+ public void setEncoding(String value) {
encoding = value;
}
@@ -250,9 +259,7 @@ void setEncoding(String value) {
/**
Set the {@link ErrorHandler} for this WriterAppender and also the
underlying {@link QuietWriter} if any. */
- public
- synchronized
- void setErrorHandler(ErrorHandler eh) {
+ public synchronized void setErrorHandler(ErrorHandler eh) {
if(eh == null) {
LogLog.warn("You have tried to set a null error-handler.");
} else {
@@ -275,9 +282,7 @@ void setErrorHandler(ErrorHandler eh) {
in different
+ places. The search order is as follows:
+
+ ControlPanel instance.
@@ -61,7 +72,7 @@ class ControlPanel extends JPanel {
add(label);
c.gridy++;
- label = new JLabel("Filter Category:");
+ label = new JLabel("Filter Logger:");
gridbag.setConstraints(label, c);
add(label);
@@ -82,9 +93,15 @@ class ControlPanel extends JPanel {
c.anchor = GridBagConstraints.WEST;
c.gridy = 0;
- final Priority[] allPriorities = Priority.getAllPossiblePriorities();
+ final Level[] allPriorities = new Level[] {Level.FATAL,
+ Level.ERROR,
+ Level.WARN,
+ Level.INFO,
+ Level.DEBUG,
+ Level.TRACE };
+
final JComboBox priorities = new JComboBox(allPriorities);
- final Priority lowest = allPriorities[allPriorities.length - 1];
+ final Level lowest = allPriorities[allPriorities.length - 1];
priorities.setSelectedItem(lowest);
aModel.setPriorityFilter(lowest);
gridbag.setConstraints(priorities, c);
diff --git a/src/java/org/apache/log4j/chainsaw/DetailPanel.java b/src/main/java/org/apache/log4j/chainsaw/DetailPanel.java
similarity index 82%
rename from src/java/org/apache/log4j/chainsaw/DetailPanel.java
rename to src/main/java/org/apache/log4j/chainsaw/DetailPanel.java
index c05198780f..1f5dfe2c83 100644
--- a/src/java/org/apache/log4j/chainsaw/DetailPanel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/DetailPanel.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.chainsaw;
import java.awt.BorderLayout;
@@ -17,7 +27,7 @@
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
/**
* A panel for showing a stack trace.
@@ -29,8 +39,8 @@ class DetailPanel
implements ListSelectionListener
{
/** used to log events **/
- private static final Category LOG =
- Category.getInstance(DetailPanel.class);
+ private static final Logger LOG =
+ Logger.getLogger(DetailPanel.class);
/** used to format the logging event **/
private static final MessageFormat FORMATTER = new MessageFormat(
@@ -38,7 +48,7 @@ class DetailPanel
" Priority: {1}" +
" Thread: {2}" +
" NDC: {3}" +
- "
Category: {4}" +
+ "
Logger: {4}" +
"
Location: {5}" +
"
Message:" +
"{6}" +
diff --git a/src/java/org/apache/log4j/chainsaw/EventDetails.java b/src/main/java/org/apache/log4j/chainsaw/EventDetails.java
similarity index 79%
rename from src/java/org/apache/log4j/chainsaw/EventDetails.java
rename to src/main/java/org/apache/log4j/chainsaw/EventDetails.java
index 12ddc51c65..4b3ad94a6a 100644
--- a/src/java/org/apache/log4j/chainsaw/EventDetails.java
+++ b/src/main/java/org/apache/log4j/chainsaw/EventDetails.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.chainsaw;
import org.apache.log4j.Priority;
@@ -73,8 +83,8 @@ class EventDetails {
EventDetails(LoggingEvent aEvent) {
this(aEvent.timeStamp,
- aEvent.level,
- aEvent.categoryName,
+ aEvent.getLevel(),
+ aEvent.getLoggerName(),
aEvent.getNDC(),
aEvent.getThreadName(),
aEvent.getRenderedMessage(),
diff --git a/src/main/java/org/apache/log4j/chainsaw/ExitAction.java b/src/main/java/org/apache/log4j/chainsaw/ExitAction.java
new file mode 100644
index 0000000000..55a100e29f
--- /dev/null
+++ b/src/main/java/org/apache/log4j/chainsaw/ExitAction.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.chainsaw;
+
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+import org.apache.log4j.Logger;
+
+/**
+ * Encapsulates the action to exit.
+ *
+ * @author Oliver Burn
+ * @version 1.0
+ */
+class ExitAction
+ extends AbstractAction
+{
+ /** use to log messages **/
+ private static final Logger LOG = Logger.getLogger(ExitAction.class);
+ /** The instance to share **/
+ public static final ExitAction INSTANCE = new ExitAction();
+
+ /** Stop people creating instances **/
+ private ExitAction() {}
+
+ /**
+ * Will shutdown the application.
+ * @param aIgnore ignored
+ */
+ public void actionPerformed(ActionEvent aIgnore) {
+ LOG.info("shutting down");
+ System.exit(0);
+ }
+}
diff --git a/src/java/org/apache/log4j/chainsaw/LoadXMLAction.java b/src/main/java/org/apache/log4j/chainsaw/LoadXMLAction.java
similarity index 81%
rename from src/java/org/apache/log4j/chainsaw/LoadXMLAction.java
rename to src/main/java/org/apache/log4j/chainsaw/LoadXMLAction.java
index 9912e7db52..33e5d13cf2 100644
--- a/src/java/org/apache/log4j/chainsaw/LoadXMLAction.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LoadXMLAction.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.chainsaw;
import java.awt.event.ActionEvent;
@@ -16,7 +26,7 @@
import javax.swing.JOptionPane;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
@@ -31,8 +41,7 @@ class LoadXMLAction
extends AbstractAction
{
/** use to log messages **/
- private static final Category LOG =
- Category.getInstance(LoadXMLAction.class);
+ private static final Logger LOG = Logger.getLogger(LoadXMLAction.class);
/** the parent frame **/
private final JFrame mParent;
diff --git a/src/java/org/apache/log4j/chainsaw/LoggingReceiver.java b/src/main/java/org/apache/log4j/chainsaw/LoggingReceiver.java
similarity index 63%
rename from src/java/org/apache/log4j/chainsaw/LoggingReceiver.java
rename to src/main/java/org/apache/log4j/chainsaw/LoggingReceiver.java
index c69b3de1d5..ca087adcc0 100644
--- a/src/java/org/apache/log4j/chainsaw/LoggingReceiver.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LoggingReceiver.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.chainsaw;
import java.io.EOFException;
@@ -23,7 +33,7 @@
*/
class LoggingReceiver extends Thread {
/** used to log messages **/
- private static final Logger logger = Logger.getLogger(LoggingReceiver.class);
+ private static final Logger LOG = Logger.getLogger(LoggingReceiver.class);
/**
* Helper that actually processes a client connection. It receives events
@@ -46,7 +56,7 @@ private class Slurper implements Runnable {
/** loops getting the events **/
public void run() {
- logger.debug("Starting to get data");
+ LOG.debug("Starting to get data");
try {
final ObjectInputStream ois =
new ObjectInputStream(mClient.getInputStream());
@@ -55,29 +65,29 @@ public void run() {
mModel.addEvent(new EventDetails(event));
}
} catch (EOFException e) {
- logger.info("Reached EOF, closing connection");
+ LOG.info("Reached EOF, closing connection");
} catch (SocketException e) {
- logger.info("Caught SocketException, closing connection");
+ LOG.info("Caught SocketException, closing connection");
} catch (IOException e) {
- logger.warn("Got IOException, closing connection", e);
+ LOG.warn("Got IOException, closing connection", e);
} catch (ClassNotFoundException e) {
- logger.warn("Got ClassNotFoundException, closing connection", e);
+ LOG.warn("Got ClassNotFoundException, closing connection", e);
}
try {
mClient.close();
} catch (IOException e) {
- logger.warn("Error closing connection", e);
+ LOG.warn("Error closing connection", e);
}
}
}
/** where to put the events **/
- private final MyTableModel mModel;
+ private MyTableModel mModel;
/** server for listening for connections **/
- private final ServerSocket mSvrSock;
-
+ private ServerSocket mSvrSock;
+
/**
* Creates a new LoggingReceiver instance.
*
@@ -93,19 +103,19 @@ public void run() {
/** Listens for client connections **/
public void run() {
- logger.info("Thread started");
+ LOG.info("Thread started");
try {
while (true) {
- logger.debug("Waiting for a connection");
+ LOG.debug("Waiting for a connection");
final Socket client = mSvrSock.accept();
- logger.debug("Got a connection from " +
+ LOG.debug("Got a connection from " +
client.getInetAddress().getHostName());
final Thread t = new Thread(new Slurper(client));
t.setDaemon(true);
t.start();
}
} catch (IOException e) {
- logger.error("Error in accepting connections, stopping.", e);
+ LOG.error("Error in accepting connections, stopping.", e);
}
}
}
diff --git a/src/java/org/apache/log4j/chainsaw/Main.java b/src/main/java/org/apache/log4j/chainsaw/Main.java
similarity index 85%
rename from src/java/org/apache/log4j/chainsaw/Main.java
rename to src/main/java/org/apache/log4j/chainsaw/Main.java
index b67a9ae476..c0c9aad71a 100644
--- a/src/java/org/apache/log4j/chainsaw/Main.java
+++ b/src/main/java/org/apache/log4j/chainsaw/Main.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.chainsaw;
import java.awt.BorderLayout;
@@ -23,7 +33,7 @@
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
/**
@@ -41,7 +51,7 @@ public class Main
public static final String PORT_PROP_NAME = "chainsaw.port";
/** use to log messages **/
- private static final Category LOG = Category.getInstance(Main.class);
+ private static final Logger LOG = Logger.getLogger(Main.class);
/**
@@ -162,7 +172,7 @@ private void setupReceiver(MyTableModel aModel) {
/** initialise log4j **/
private static void initLog4J() {
final Properties props = new Properties();
- props.setProperty("log4j.rootCategory", "DEBUG, A1");
+ props.setProperty("log4j.rootLogger", "DEBUG, A1");
props.setProperty("log4j.appender.A1",
"org.apache.log4j.ConsoleAppender");
props.setProperty("log4j.appender.A1.layout",
diff --git a/src/java/org/apache/log4j/chainsaw/MyTableModel.java b/src/main/java/org/apache/log4j/chainsaw/MyTableModel.java
similarity index 92%
rename from src/java/org/apache/log4j/chainsaw/MyTableModel.java
rename to src/main/java/org/apache/log4j/chainsaw/MyTableModel.java
index d1af076317..0d43272c9a 100644
--- a/src/java/org/apache/log4j/chainsaw/MyTableModel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/MyTableModel.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.chainsaw;
import java.text.DateFormat;
@@ -16,7 +26,7 @@
import java.util.TreeSet;
import javax.swing.table.AbstractTableModel;
import org.apache.log4j.Priority;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
/**
* Represents a list of EventDetails objects that are sorted on
@@ -29,8 +39,7 @@ class MyTableModel
{
/** used to log messages **/
- private static final Category LOG =
- Category.getInstance(MyTableModel.class);
+ private static final Logger LOG = Logger.getLogger(MyTableModel.class);
/** use the compare logging events **/
private static final Comparator MY_COMP = new Comparator()
diff --git a/src/java/org/apache/log4j/chainsaw/XMLFileHandler.java b/src/main/java/org/apache/log4j/chainsaw/XMLFileHandler.java
similarity index 76%
rename from src/java/org/apache/log4j/chainsaw/XMLFileHandler.java
rename to src/main/java/org/apache/log4j/chainsaw/XMLFileHandler.java
index 5ce82d0744..2f9af5125e 100644
--- a/src/java/org/apache/log4j/chainsaw/XMLFileHandler.java
+++ b/src/main/java/org/apache/log4j/chainsaw/XMLFileHandler.java
@@ -1,13 +1,23 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.chainsaw;
import java.util.StringTokenizer;
-import org.apache.log4j.Priority;
+import org.apache.log4j.Level;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
@@ -37,13 +47,11 @@ class XMLFileHandler
private final MyTableModel mModel;
/** the number of events in the document **/
private int mNumEvents;
- /** the current element being parsed **/
- private String mCurrentElement;
/** the time of the event **/
private long mTimeStamp;
- /** the priority of the event **/
- private Priority mPriority;
+ /** the priority (level) of the event **/
+ private Level mLevel;
/** the category of the event **/
private String mCategoryName;
/** the NDC for the event **/
@@ -56,7 +64,8 @@ class XMLFileHandler
private String[] mThrowableStrRep;
/** the location details for the event **/
private String mLocationDetails;
-
+ /** buffer for collecting text **/
+ private final StringBuffer mBuf = new StringBuffer();
/**
* Creates a new XMLFileHandler instance.
@@ -76,21 +85,7 @@ public void startDocument()
/** @see DefaultHandler **/
public void characters(char[] aChars, int aStart, int aLength) {
- if (mCurrentElement == TAG_NDC) {
- mNDC = new String(aChars, aStart, aLength);
- } else if (mCurrentElement == TAG_MESSAGE) {
- mMessage = new String(aChars, aStart, aLength);
- } else if (mCurrentElement == TAG_THROWABLE) {
- final StringTokenizer st =
- new StringTokenizer(new String(aChars, aStart, aLength), "\t");
- mThrowableStrRep = new String[st.countTokens()];
- if (mThrowableStrRep.length > 0) {
- mThrowableStrRep[0] = st.nextToken();
- for (int i = 1; i < mThrowableStrRep.length; i++) {
- mThrowableStrRep[i] = "\t" + st.nextToken();
- }
- }
- }
+ mBuf.append(String.valueOf(aChars, aStart, aLength));
}
/** @see DefaultHandler **/
@@ -101,8 +96,20 @@ public void endElement(String aNamespaceURI,
if (TAG_EVENT.equals(aQName)) {
addEvent();
resetData();
- } else if (mCurrentElement != TAG_EVENT) {
- mCurrentElement = TAG_EVENT; // hack - but only thing I care about
+ } else if (TAG_NDC.equals(aQName)) {
+ mNDC = mBuf.toString();
+ } else if (TAG_MESSAGE.equals(aQName)) {
+ mMessage = mBuf.toString();
+ } else if (TAG_THROWABLE.equals(aQName)) {
+ final StringTokenizer st =
+ new StringTokenizer(mBuf.toString(), "\n\t");
+ mThrowableStrRep = new String[st.countTokens()];
+ if (mThrowableStrRep.length > 0) {
+ mThrowableStrRep[0] = st.nextToken();
+ for (int i = 1; i < mThrowableStrRep.length; i++) {
+ mThrowableStrRep[i] = "\t" + st.nextToken();
+ }
+ }
}
}
@@ -112,22 +119,18 @@ public void startElement(String aNamespaceURI,
String aQName,
Attributes aAtts)
{
+ mBuf.setLength(0);
+
if (TAG_EVENT.equals(aQName)) {
mThreadName = aAtts.getValue("thread");
mTimeStamp = Long.parseLong(aAtts.getValue("timestamp"));
- mCategoryName = aAtts.getValue("category");
- mPriority = Priority.toPriority(aAtts.getValue("level"));
+ mCategoryName = aAtts.getValue("logger");
+ mLevel = Level.toLevel(aAtts.getValue("level"));
} else if (TAG_LOCATION_INFO.equals(aQName)) {
mLocationDetails = aAtts.getValue("class") + "."
+ aAtts.getValue("method")
+ "(" + aAtts.getValue("file") + ":" + aAtts.getValue("line")
+ ")";
- } else if (TAG_NDC.equals(aQName)) {
- mCurrentElement = TAG_NDC;
- } else if (TAG_MESSAGE.equals(aQName)) {
- mCurrentElement = TAG_MESSAGE;
- } else if (TAG_THROWABLE.equals(aQName)) {
- mCurrentElement = TAG_THROWABLE;
}
}
@@ -143,7 +146,7 @@ int getNumEvents() {
/** Add an event to the model **/
private void addEvent() {
mModel.addEvent(new EventDetails(mTimeStamp,
- mPriority,
+ mLevel,
mCategoryName,
mNDC,
mThreadName,
@@ -156,7 +159,7 @@ private void addEvent() {
/** Reset the data for an event **/
private void resetData() {
mTimeStamp = 0;
- mPriority = null;
+ mLevel = null;
mCategoryName = null;
mNDC = null;
mThreadName = null;
diff --git a/src/java/org/apache/log4j/chainsaw/doc-files/screen_01.png b/src/main/java/org/apache/log4j/chainsaw/doc-files/screen_01.png
similarity index 100%
rename from src/java/org/apache/log4j/chainsaw/doc-files/screen_01.png
rename to src/main/java/org/apache/log4j/chainsaw/doc-files/screen_01.png
diff --git a/src/java/org/apache/log4j/chainsaw/package.html b/src/main/java/org/apache/log4j/chainsaw/package.html
similarity index 100%
rename from src/java/org/apache/log4j/chainsaw/package.html
rename to src/main/java/org/apache/log4j/chainsaw/package.html
diff --git a/src/java/org/apache/log4j/config/PropertyGetter.java b/src/main/java/org/apache/log4j/config/PropertyGetter.java
similarity index 74%
rename from src/java/org/apache/log4j/config/PropertyGetter.java
rename to src/main/java/org/apache/log4j/config/PropertyGetter.java
index 3c6f8db373..01f7d775de 100644
--- a/src/java/org/apache/log4j/config/PropertyGetter.java
+++ b/src/main/java/org/apache/log4j/config/PropertyGetter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.config;
diff --git a/src/java/org/apache/log4j/config/PropertyPrinter.java b/src/main/java/org/apache/log4j/config/PropertyPrinter.java
similarity index 66%
rename from src/java/org/apache/log4j/config/PropertyPrinter.java
rename to src/main/java/org/apache/log4j/config/PropertyPrinter.java
index 23c950cf10..6462e3a741 100644
--- a/src/java/org/apache/log4j/config/PropertyPrinter.java
+++ b/src/main/java/org/apache/log4j/config/PropertyPrinter.java
@@ -1,16 +1,31 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.config;
-import java.io.*;
-import java.util.*;
-import org.apache.log4j.*;
+import org.apache.log4j.Appender;
+import org.apache.log4j.Category;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.Hashtable;
/**
Prints the configuration of the log4j default hierarchy
@@ -46,8 +61,8 @@ String genAppName() {
}
/**
- Returns true if the specified appender name is considered to have
- been generated, i.e. if it is of the form A[0-9]+.
+ * Returns true if the specified appender name is considered to have
+ * been generated, that is, if it is of the form A[0-9]+.
*/
protected
boolean isGenAppName(String name) {
@@ -67,11 +82,11 @@ boolean isGenAppName(String name) {
*/
public
void print(PrintWriter out) {
- printOptions(out, Category.getRoot());
+ printOptions(out, Logger.getRootLogger());
- Enumeration cats = Category.getCurrentCategories();
+ Enumeration cats = LogManager.getCurrentLoggers();
while (cats.hasMoreElements()) {
- printOptions(out, (Category) cats.nextElement());
+ printOptions(out, (Logger) cats.nextElement());
}
}
@@ -100,12 +115,19 @@ void printOptions(PrintWriter out, Category cat) {
}
appenderString += ", " + name;
}
- String catKey = (cat == Category.getRoot())
- ? "log4j.rootCategory"
- : "log4j.category." + cat.getName();
+ String catKey = (cat == Logger.getRootLogger())
+ ? "log4j.rootLogger"
+ : "log4j.logger." + cat.getName();
if (appenderString != "") {
out.println(catKey + "=" + appenderString);
}
+ if (!cat.getAdditivity() && cat != Logger.getRootLogger()) {
+ out.println("log4j.additivity." + cat.getName() + "=false");
+ }
+ }
+
+ protected void printOptions(PrintWriter out, Logger cat) {
+ printOptions(out, (Category) cat);
}
protected
diff --git a/src/java/org/apache/log4j/config/PropertySetter.java b/src/main/java/org/apache/log4j/config/PropertySetter.java
similarity index 89%
rename from src/java/org/apache/log4j/config/PropertySetter.java
rename to src/main/java/org/apache/log4j/config/PropertySetter.java
index c1b2ec1ad9..559923df51 100644
--- a/src/java/org/apache/log4j/config/PropertySetter.java
+++ b/src/main/java/org/apache/log4j/config/PropertySetter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.APL file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
// Contributors: Georg Lundesgaard
@@ -156,7 +165,7 @@ void setProperty(String name, String value) {
setProperty(prop, name, value);
} catch (PropertySetterException ex) {
LogLog.warn("Failed to set property [" + name +
- "] to value \"" + value + "\". " + ex.getMessage());
+ "] to value \"" + value + "\". ", ex.rootCause);
}
}
}
diff --git a/src/main/java/org/apache/log4j/config/PropertySetterException.java b/src/main/java/org/apache/log4j/config/PropertySetterException.java
new file mode 100644
index 0000000000..c6314cca41
--- /dev/null
+++ b/src/main/java/org/apache/log4j/config/PropertySetterException.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.config;
+
+/**
+ * Thrown when an error is encountered whilst attempting to set a property
+ * using the {@link PropertySetter} utility class.
+ *
+ * @author Anders Kristensen
+ * @since 1.1
+ */
+public class PropertySetterException extends Exception {
+ private static final long serialVersionUID = -1352613734254235861L;
+ protected Throwable rootCause;
+
+ public
+ PropertySetterException(String msg) {
+ super(msg);
+ }
+
+ public
+ PropertySetterException(Throwable rootCause)
+ {
+ super();
+ this.rootCause = rootCause;
+ }
+
+ /**
+ Returns descriptive text on the cause of this exception.
+ */
+ public
+ String getMessage() {
+ String msg = super.getMessage();
+ if (msg == null && rootCause != null) {
+ msg = rootCause.getMessage();
+ }
+ return msg;
+ }
+}
diff --git a/src/java/org/apache/log4j/config/package.html b/src/main/java/org/apache/log4j/config/package.html
similarity index 100%
rename from src/java/org/apache/log4j/config/package.html
rename to src/main/java/org/apache/log4j/config/package.html
diff --git a/src/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java b/src/main/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java
similarity index 78%
rename from src/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java
rename to src/main/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java
index c17bc8cf9e..4547ecea63 100644
--- a/src/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java
+++ b/src/main/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.helpers;
@@ -25,6 +35,7 @@
@since 0.7.5
*/
public class AbsoluteTimeDateFormat extends DateFormat {
+ private static final long serialVersionUID = -388856345976723342L;
/**
String constant used to specify {@link
diff --git a/src/java/org/apache/log4j/helpers/AppenderAttachableImpl.java b/src/main/java/org/apache/log4j/helpers/AppenderAttachableImpl.java
similarity index 81%
rename from src/java/org/apache/log4j/helpers/AppenderAttachableImpl.java
rename to src/main/java/org/apache/log4j/helpers/AppenderAttachableImpl.java
index ec01c769e7..0e8cd38283 100644
--- a/src/java/org/apache/log4j/helpers/AppenderAttachableImpl.java
+++ b/src/main/java/org/apache/log4j/helpers/AppenderAttachableImpl.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
@@ -121,8 +130,8 @@ boolean isAttached(Appender appender) {
/**
- Remove all previously attached appenders.
- */
+ * Remove and close all previously attached appenders.
+ * */
public
void removeAllAppenders() {
if(appenderList != null) {
diff --git a/src/java/org/apache/log4j/helpers/BoundedFIFO.java b/src/main/java/org/apache/log4j/helpers/BoundedFIFO.java
similarity index 80%
rename from src/java/org/apache/log4j/helpers/BoundedFIFO.java
rename to src/main/java/org/apache/log4j/helpers/BoundedFIFO.java
index 2a1796654a..e5ce96ce02 100644
--- a/src/java/org/apache/log4j/helpers/BoundedFIFO.java
+++ b/src/main/java/org/apache/log4j/helpers/BoundedFIFO.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
// Contributors: Mathias Bogaert
@@ -82,8 +91,8 @@ int getMaxSize() {
}
/**
- Return true if the buffer is full, i.e. of the
- number of elements in the buffer equals the buffer size. */
+ Return true if the buffer is full, that is, whether
+ the number of elements in the buffer equals the buffer size. */
public
boolean isFull() {
return numElements == maxSize;
diff --git a/src/java/org/apache/log4j/helpers/CountingQuietWriter.java b/src/main/java/org/apache/log4j/helpers/CountingQuietWriter.java
similarity index 50%
rename from src/java/org/apache/log4j/helpers/CountingQuietWriter.java
rename to src/main/java/org/apache/log4j/helpers/CountingQuietWriter.java
index 26cf132d7e..55199e47a3 100644
--- a/src/java/org/apache/log4j/helpers/CountingQuietWriter.java
+++ b/src/main/java/org/apache/log4j/helpers/CountingQuietWriter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
diff --git a/src/java/org/apache/log4j/helpers/CyclicBuffer.java b/src/main/java/org/apache/log4j/helpers/CyclicBuffer.java
similarity index 79%
rename from src/java/org/apache/log4j/helpers/CyclicBuffer.java
rename to src/main/java/org/apache/log4j/helpers/CyclicBuffer.java
index 91da4efa5f..9077847dc9 100644
--- a/src/java/org/apache/log4j/helpers/CyclicBuffer.java
+++ b/src/main/java/org/apache/log4j/helpers/CyclicBuffer.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
diff --git a/src/java/org/apache/log4j/helpers/DateLayout.java b/src/main/java/org/apache/log4j/helpers/DateLayout.java
similarity index 87%
rename from src/java/org/apache/log4j/helpers/DateLayout.java
rename to src/main/java/org/apache/log4j/helpers/DateLayout.java
index 9dba0c6b26..2e0eca8e34 100644
--- a/src/java/org/apache/log4j/helpers/DateLayout.java
+++ b/src/main/java/org/apache/log4j/helpers/DateLayout.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
diff --git a/src/java/org/apache/log4j/helpers/DateTimeDateFormat.java b/src/main/java/org/apache/log4j/helpers/DateTimeDateFormat.java
similarity index 61%
rename from src/java/org/apache/log4j/helpers/DateTimeDateFormat.java
rename to src/main/java/org/apache/log4j/helpers/DateTimeDateFormat.java
index e4db3f3aa5..559f731952 100644
--- a/src/java/org/apache/log4j/helpers/DateTimeDateFormat.java
+++ b/src/main/java/org/apache/log4j/helpers/DateTimeDateFormat.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.helpers;
@@ -15,13 +25,14 @@
import java.text.DateFormatSymbols;
/**
- Formats a {@link Date} in the format "dd MMM YYYY HH:mm:ss,SSS" for example,
+ Formats a {@link Date} in the format "dd MMM yyyy HH:mm:ss,SSS" for example,
"06 Nov 1994 15:49:37,459".
@author Ceki Gülcü
@since 0.7.5
*/
public class DateTimeDateFormat extends AbsoluteTimeDateFormat {
+ private static final long serialVersionUID = 5547637772208514971L;
String[] shortMonths;
@@ -38,7 +49,7 @@ public class DateTimeDateFormat extends AbsoluteTimeDateFormat {
}
/**
- Appends to sbuf the date in the format "dd MMM YYYY
+ Appends to sbuf the date in the format "dd MMM yyyy
HH:mm:ss,SSS" for example, "06 Nov 1994 08:49:37,459".
@param sbuf the string buffer to write to
diff --git a/src/java/org/apache/log4j/helpers/FileWatchdog.java b/src/main/java/org/apache/log4j/helpers/FileWatchdog.java
similarity index 72%
rename from src/java/org/apache/log4j/helpers/FileWatchdog.java
rename to src/main/java/org/apache/log4j/helpers/FileWatchdog.java
index 4579fbe33a..8fc86339ec 100644
--- a/src/java/org/apache/log4j/helpers/FileWatchdog.java
+++ b/src/main/java/org/apache/log4j/helpers/FileWatchdog.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
// Contributors: Mathias Bogaert
@@ -92,7 +101,7 @@ void checkAndConfigure() {
void run() {
while(!interrupted) {
try {
- Thread.currentThread().sleep(delay);
+ Thread.sleep(delay);
} catch(InterruptedException e) {
// no interruption expected
}
diff --git a/src/main/java/org/apache/log4j/helpers/FormattingInfo.java b/src/main/java/org/apache/log4j/helpers/FormattingInfo.java
new file mode 100644
index 0000000000..e158243235
--- /dev/null
+++ b/src/main/java/org/apache/log4j/helpers/FormattingInfo.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.helpers;
+
+
+/**
+ FormattingInfo instances contain the information obtained when parsing
+ formatting modifiers in conversion modifiers.
+
+ @author Jim Cakalic
+ @author Ceki Gülcü
+
+ @since 0.8.2
+ */
+public class FormattingInfo {
+ int min = -1;
+ int max = 0x7FFFFFFF;
+ boolean leftAlign = false;
+
+ void reset() {
+ min = -1;
+ max = 0x7FFFFFFF;
+ leftAlign = false;
+ }
+
+ void dump() {
+ LogLog.debug("min="+min+", max="+max+", leftAlign="+leftAlign);
+ }
+}
+
diff --git a/src/java/org/apache/log4j/helpers/ISO8601DateFormat.java b/src/main/java/org/apache/log4j/helpers/ISO8601DateFormat.java
similarity index 78%
rename from src/java/org/apache/log4j/helpers/ISO8601DateFormat.java
rename to src/main/java/org/apache/log4j/helpers/ISO8601DateFormat.java
index b4edd13c53..6a131db8fa 100644
--- a/src/java/org/apache/log4j/helpers/ISO8601DateFormat.java
+++ b/src/main/java/org/apache/log4j/helpers/ISO8601DateFormat.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
@@ -17,7 +26,7 @@
// Contributors: Arndt Schoenewald
+
+
+ */
+ static public URL getResource(String resource) {
+ ClassLoader classLoader = null;
+ URL url = null;
+
+ try {
+ if(!java1) {
+ classLoader = getTCL();
+ if(classLoader != null) {
+ LogLog.debug("Trying to find ["+resource+"] using context classloader "
+ +classLoader+".");
+ url = classLoader.getResource(resource);
+ if(url != null) {
+ return url;
+ }
+ }
+ }
+
+ // We could not find resource. Ler us now try with the
+ // classloader that loaded this class.
+ classLoader = Loader.class.getClassLoader();
+ if(classLoader != null) {
+ LogLog.debug("Trying to find ["+resource+"] using "+classLoader
+ +" class loader.");
+ url = classLoader.getResource(resource);
+ if(url != null) {
+ return url;
+ }
+ }
+ } catch(Throwable t) {
+ LogLog.warn(TSTR, t);
+ }
+
+ // Last ditch attempt: get the resource from the class path. It
+ // may be the case that clazz was loaded by the Extentsion class
+ // loader which the parent of the system class loader. Hence the
+ // code below.
+ LogLog.debug("Trying to find ["+resource+
+ "] using ClassLoader.getSystemResource().");
+ return ClassLoader.getSystemResource(resource);
+ }
+
+ /**
+ Are we running under JDK 1.x?
+ */
+ public
+ static
+ boolean isJava1() {
+ return java1;
+ }
+
+ /**
+ * Get the Thread Context Loader which is a JDK 1.2 feature. If we
+ * are running under JDK 1.1 or anything else goes wrong the method
+ * returns resource using the thread context
+ class loader under Java2. If that fails, search for
+ resource using the class loader that loaded this
+ class (Loader). Under JDK 1.1, only the the class
+ loader that loaded this class (Loader) is used.
+
+ ClassLoader.getSystemResource(resource), that is is
+ using the system class loader in JDK 1.2 and virtual machine's
+ built-in class loader in JDK 1.1.
+
+ null.
+ *
+ * */
+ private static ClassLoader getTCL() throws IllegalAccessException,
+ InvocationTargetException {
+
+ // Are we running on a JDK 1.2 or later system?
+ Method method = null;
+ try {
+ method = Thread.class.getMethod("getContextClassLoader", null);
+ } catch (NoSuchMethodException e) {
+ // We are running on JDK 1.1
+ return null;
+ }
+
+ return (ClassLoader) method.invoke(Thread.currentThread(), null);
+ }
+
+
+
+ /**
+ * If running under JDK 1.2 load the specified class using the
+ * Thread contextClassLoader if that
+ * fails try Class.forname. Under JDK 1.1 only Class.forName is
+ * used.
+ *
+ */
+ static public Class loadClass (String clazz) throws ClassNotFoundException {
+ // Just call Class.forName(clazz) if we are running under JDK 1.1
+ // or if we are instructed to ignore the TCL.
+ if(java1 || ignoreTCL) {
+ return Class.forName(clazz);
+ } else {
+ try {
+ return getTCL().loadClass(clazz);
+ } catch(Throwable e) {
+ // we reached here because tcl was null or because of a
+ // security exception, or because clazz could not be loaded...
+ // In any case we now try one more time
+ return Class.forName(clazz);
+ }
+ }
+ }
+}
diff --git a/src/java/org/apache/log4j/helpers/LogLog.java b/src/main/java/org/apache/log4j/helpers/LogLog.java
similarity index 84%
rename from src/java/org/apache/log4j/helpers/LogLog.java
rename to src/main/java/org/apache/log4j/helpers/LogLog.java
index 5c98715b0e..a7bd588ff1 100644
--- a/src/java/org/apache/log4j/helpers/LogLog.java
+++ b/src/main/java/org/apache/log4j/helpers/LogLog.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
diff --git a/src/main/java/org/apache/log4j/helpers/NullEnumeration.java b/src/main/java/org/apache/log4j/helpers/NullEnumeration.java
new file mode 100644
index 0000000000..0f4310ddfa
--- /dev/null
+++ b/src/main/java/org/apache/log4j/helpers/NullEnumeration.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.helpers;
+
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+/**
+
+ An always-empty Enumerator.
+
+ @author Anders Kristensen
+ @since version 1.0
+ */
+public class NullEnumeration implements Enumeration {
+ private static final NullEnumeration instance = new NullEnumeration();
+
+ private
+ NullEnumeration() {
+ }
+
+ public static NullEnumeration getInstance() {
+ return instance;
+ }
+
+ public
+ boolean hasMoreElements() {
+ return false;
+ }
+
+ public
+ Object nextElement() {
+ throw new NoSuchElementException();
+ }
+}
diff --git a/src/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java b/src/main/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java
similarity index 70%
rename from src/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java
rename to src/main/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java
index a793e09189..33ed0f9242 100644
--- a/src/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java
+++ b/src/main/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
diff --git a/src/java/org/apache/log4j/helpers/OptionConverter.java b/src/main/java/org/apache/log4j/helpers/OptionConverter.java
similarity index 91%
rename from src/java/org/apache/log4j/helpers/OptionConverter.java
rename to src/main/java/org/apache/log4j/helpers/OptionConverter.java
index 2131b48d71..1d2d7dc18c 100644
--- a/src/java/org/apache/log4j/helpers/OptionConverter.java
+++ b/src/main/java/org/apache/log4j/helpers/OptionConverter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
@@ -174,6 +183,8 @@ significant for the class name part, if present.
Level toLevel(String value, Level defaultValue) {
if(value == null)
return defaultValue;
+
+ value = value.trim();
int hashIndex = value.indexOf('#');
if (hashIndex == -1) {
@@ -199,7 +210,7 @@ Level toLevel(String value, Level defaultValue) {
+ ":pri=[" + levelName + "]");
try {
- Class customLevel = Class.forName(clazz);
+ Class customLevel = Loader.loadClass(clazz);
// get a ref to the specified class' static method
// toLevel(String, org.apache.log4j.Level)
@@ -218,7 +229,7 @@ Level toLevel(String value, Level defaultValue) {
LogLog.warn("custom level class [" + clazz + "] not found.");
} catch(NoSuchMethodException e) {
LogLog.warn("custom level class [" + clazz + "]"
- + " does not have a constructor which takes one string parameter", e);
+ + " does not have a class function toLevel(String, Level)", e);
} catch(java.lang.reflect.InvocationTargetException e) {
LogLog.warn("custom level class [" + clazz + "]"
+ " could not be instantiated", e);
@@ -306,10 +317,14 @@ Object instantiateByClassName(String className, Class superClass,
Object defaultValue) {
if(className != null) {
try {
- Class classObj = Class.forName(className);
+ Class classObj = Loader.loadClass(className);
if(!superClass.isAssignableFrom(classObj)) {
LogLog.error("A \""+className+"\" object is not assignable to a \""+
superClass.getName() + "\" variable.");
+ LogLog.error("The class \""+ superClass.getName()+"\" was loaded by ");
+ LogLog.error("["+superClass.getClassLoader()+"] whereas object of type ");
+ LogLog.error("\"" +classObj.getName()+"\" was loaded by ["
+ +classObj.getClassLoader()+"].");
return defaultValue;
}
return classObj.newInstance();
diff --git a/src/java/org/apache/log4j/helpers/PatternConverter.java b/src/main/java/org/apache/log4j/helpers/PatternConverter.java
similarity index 71%
rename from src/java/org/apache/log4j/helpers/PatternConverter.java
rename to src/main/java/org/apache/log4j/helpers/PatternConverter.java
index d8b7bdfeda..2b46db7fee 100644
--- a/src/java/org/apache/log4j/helpers/PatternConverter.java
+++ b/src/main/java/org/apache/log4j/helpers/PatternConverter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
diff --git a/src/java/org/apache/log4j/helpers/PatternParser.java b/src/main/java/org/apache/log4j/helpers/PatternParser.java
similarity index 94%
rename from src/java/org/apache/log4j/helpers/PatternParser.java
rename to src/main/java/org/apache/log4j/helpers/PatternParser.java
index f6fecf39e5..73a35a582f 100644
--- a/src/java/org/apache/log4j/helpers/PatternParser.java
+++ b/src/main/java/org/apache/log4j/helpers/PatternParser.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
@@ -40,7 +49,6 @@ public class PatternParser {
private static final int LITERAL_STATE = 0;
private static final int CONVERTER_STATE = 1;
- private static final int MINUS_STATE = 2;
private static final int DOT_STATE = 3;
private static final int MIN_STATE = 4;
private static final int MAX_STATE = 5;
@@ -388,7 +396,7 @@ String convert(LoggingEvent event) {
case THREAD_CONVERTER:
return event.getThreadName();
case LEVEL_CONVERTER:
- return event.level.toString();
+ return event.getLevel().toString();
case NDC_CONVERTER:
return event.getNDC();
case MESSAGE_CONVERTER: {
@@ -538,7 +546,7 @@ private class CategoryPatternConverter extends NamedPatternConverter {
}
String getFullyQualifiedName(LoggingEvent event) {
- return event.categoryName;
+ return event.getLoggerName();
}
}
}
diff --git a/src/java/org/apache/log4j/helpers/QuietWriter.java b/src/main/java/org/apache/log4j/helpers/QuietWriter.java
similarity index 61%
rename from src/java/org/apache/log4j/helpers/QuietWriter.java
rename to src/main/java/org/apache/log4j/helpers/QuietWriter.java
index f000d0eef3..68a96da8d1 100644
--- a/src/java/org/apache/log4j/helpers/QuietWriter.java
+++ b/src/main/java/org/apache/log4j/helpers/QuietWriter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.helpers;
diff --git a/src/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java b/src/main/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java
similarity index 52%
rename from src/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java
rename to src/main/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java
index 85b6394e00..ab81a34cf5 100644
--- a/src/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java
+++ b/src/main/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.helpers;
@@ -14,7 +24,7 @@
/**
Formats a {@link Date} by printing the number of milliseconds
- elapsed since the start of the application. This is the fastest
+ elapsed since construction of the format. This is the fastest
printing DateFormat in the package.
@author Ceki Gülcü
@@ -22,6 +32,8 @@
@since 0.7.5
*/
public class RelativeTimeDateFormat extends DateFormat {
+ private static final long serialVersionUID = 7055751607085611984L;
+
protected final long startTime;
diff --git a/src/main/java/org/apache/log4j/helpers/SyslogQuietWriter.java b/src/main/java/org/apache/log4j/helpers/SyslogQuietWriter.java
new file mode 100644
index 0000000000..62e933e40d
--- /dev/null
+++ b/src/main/java/org/apache/log4j/helpers/SyslogQuietWriter.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.helpers;
+
+
+
+import java.io.Writer;
+import org.apache.log4j.spi.ErrorHandler;
+
+/**
+ SyslogQuietWriter extends QuietWriter by prepending the syslog
+ level code before each printed String.
+
+ @since 0.7.3
+*/
+public class SyslogQuietWriter extends QuietWriter {
+
+ int syslogFacility;
+ int level;
+
+ public
+ SyslogQuietWriter(Writer writer, int syslogFacility, ErrorHandler eh) {
+ super(writer, eh);
+ this.syslogFacility = syslogFacility;
+ }
+
+ public
+ void setLevel(int level) {
+ this.level = level;
+ }
+
+ public
+ void setSyslogFacility(int syslogFacility) {
+ this.syslogFacility = syslogFacility;
+ }
+
+ public
+ void write(String string) {
+ super.write("<"+(syslogFacility | level)+">" + string);
+ }
+}
diff --git a/src/main/java/org/apache/log4j/helpers/SyslogWriter.java b/src/main/java/org/apache/log4j/helpers/SyslogWriter.java
new file mode 100644
index 0000000000..d6ce4bf6de
--- /dev/null
+++ b/src/main/java/org/apache/log4j/helpers/SyslogWriter.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.helpers;
+
+
+import java.io.Writer;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.DatagramPacket;
+import java.net.UnknownHostException;
+import java.net.SocketException;
+import java.io.IOException;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ SyslogWriter is a wrapper around the java.net.DatagramSocket class
+ so that it behaves like a java.io.Writer.
+
+ @since 0.7.3
+*/
+public class SyslogWriter extends Writer {
+
+ final int SYSLOG_PORT = 514;
+ /**
+ * Host string from last constructed SyslogWriter.
+ * @deprecated
+ */
+ static String syslogHost;
+
+ private InetAddress address;
+ private final int port;
+ private DatagramSocket ds;
+
+ /**
+ * Constructs a new instance of SyslogWriter.
+ * @param syslogHost host name, may not be null. A port
+ * may be specified by following the name or IPv4 literal address with
+ * a colon and a decimal port number. To specify a port with an IPv6
+ * address, enclose the IPv6 address in square brackets before appending
+ * the colon and decimal port number.
+ */
+ public
+ SyslogWriter(final String syslogHost) {
+ SyslogWriter.syslogHost = syslogHost;
+ if (syslogHost == null) {
+ throw new NullPointerException("syslogHost");
+ }
+
+ String host = syslogHost;
+ int urlPort = -1;
+
+ //
+ // If not an unbracketed IPv6 address then
+ // parse as a URL
+ //
+ if (host.indexOf("[") != -1 || host.indexOf(':') == host.lastIndexOf(':')) {
+ try {
+ URL url = new URL("http://" + host);
+ if (url.getHost() != null) {
+ host = url.getHost();
+ // if host is a IPv6 literal, strip off the brackets
+ if(host.startsWith("[") && host.charAt(host.length() - 1) == ']') {
+ host = host.substring(1, host.length() - 1);
+ }
+ urlPort = url.getPort();
+ }
+ } catch(MalformedURLException e) {
+ LogLog.error("Malformed URL: will attempt to interpret as InetAddress.", e);
+ }
+ }
+
+ if (urlPort == -1) {
+ urlPort = SYSLOG_PORT;
+ }
+ port = urlPort;
+
+ try {
+ this.address = InetAddress.getByName(host);
+ }
+ catch (UnknownHostException e) {
+ LogLog.error("Could not find " + host +
+ ". All logging will FAIL.", e);
+ }
+
+ try {
+ this.ds = new DatagramSocket();
+ }
+ catch (SocketException e) {
+ e.printStackTrace();
+ LogLog.error("Could not instantiate DatagramSocket to " + host +
+ ". All logging will FAIL.", e);
+ }
+
+ }
+
+
+ public
+ void write(char[] buf, int off, int len) throws IOException {
+ this.write(new String(buf, off, len));
+ }
+
+ public
+ void write(final String string) throws IOException {
+
+ if(this.ds != null && this.address != null) {
+ byte[] bytes = string.getBytes();
+ //
+ // syslog packets must be less than 1024 bytes
+ //
+ int bytesLength = bytes.length;
+ if (bytesLength >= 1024) {
+ bytesLength = 1024;
+ }
+ DatagramPacket packet = new DatagramPacket(bytes, bytesLength,
+ address, port);
+ ds.send(packet);
+ }
+
+ }
+
+ public
+ void flush() {}
+
+ public void close() {
+ if (ds != null) {
+ ds.close();
+ }
+ }
+}
diff --git a/src/main/java/org/apache/log4j/helpers/ThreadLocalMap.java b/src/main/java/org/apache/log4j/helpers/ThreadLocalMap.java
new file mode 100644
index 0000000000..da60c86ff4
--- /dev/null
+++ b/src/main/java/org/apache/log4j/helpers/ThreadLocalMap.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.helpers;
+
+import java.util.Hashtable;
+
+/**
+ ThreadLocalMap extends {@link InheritableThreadLocal}
+ to bequeath a copy of the hashtable of the MDC of the parent
+ thread.
+
+ @author Ceki Gülcü
+ @since 1.2
+*/
+final public class ThreadLocalMap extends InheritableThreadLocal {
+
+ public
+ final
+ Object childValue(Object parentValue) {
+ Hashtable ht = (Hashtable) parentValue;
+ if(ht != null) {
+ return ht.clone();
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/org/apache/log4j/helpers/Transform.java b/src/main/java/org/apache/log4j/helpers/Transform.java
new file mode 100644
index 0000000000..7626e71fb9
--- /dev/null
+++ b/src/main/java/org/apache/log4j/helpers/Transform.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.helpers;
+
+/**
+ Utility class for transforming strings.
+
+ @author Ceki Gülcü
+ @author Michael A. McAngus
+ */
+public class Transform {
+
+ private static final String CDATA_START = "";
+ private static final String CDATA_PSEUDO_END = "]]>";
+ private static final String CDATA_EMBEDED_END = CDATA_END + CDATA_PSEUDO_END + CDATA_START;
+ private static final int CDATA_END_LEN = CDATA_END.length();
+
+ /**
+ * This method takes a string which may contain HTML tags (ie,
+ * <b>, <table>, etc) and replaces any
+ * '<', '>' , '&' or '"'
+ * characters with respective predefined entity references.
+ *
+ * @param input The text to be converted.
+ * @return The input string with the special characters replaced.
+ * */
+ static public String escapeTags(final String input) {
+ //Check if the string is null, zero length or devoid of special characters
+ // if so, return what was sent in.
+
+ if(input == null
+ || input.length() == 0
+ || (input.indexOf('"') == -1 &&
+ input.indexOf('&') == -1 &&
+ input.indexOf('<') == -1 &&
+ input.indexOf('>') == -1)) {
+ return input;
+ }
+
+ //Use a StringBuffer in lieu of String concatenation -- it is
+ //much more efficient this way.
+
+ StringBuffer buf = new StringBuffer(input.length() + 6);
+ char ch = ' ';
+
+ int len = input.length();
+ for(int i=0; i < len; i++) {
+ ch = input.charAt(i);
+ if (ch > '>') {
+ buf.append(ch);
+ } else if(ch == '<') {
+ buf.append("<");
+ } else if(ch == '>') {
+ buf.append(">");
+ } else if(ch == '&') {
+ buf.append("&");
+ } else if(ch == '"') {
+ buf.append(""");
+ } else {
+ buf.append(ch);
+ }
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Ensures that embeded CDEnd strings (]]>) are handled properly
+ * within message, NDC and throwable tag text.
+ *
+ * @param buf StringBuffer holding the XML data to this point. The
+ * initial CDStart () of the CDATA
+ * section are the responsibility of the calling method.
+ * @param str The String that is inserted into an existing CDATA Section within buf.
+ * */
+ static public void appendEscapingCDATA(final StringBuffer buf,
+ final String str) {
+ if (str != null) {
+ int end = str.indexOf(CDATA_END);
+ if (end < 0) {
+ buf.append(str);
+ } else {
+ int start = 0;
+ while (end > -1) {
+ buf.append(str.substring(start, end));
+ buf.append(CDATA_EMBEDED_END);
+ start = end + CDATA_END_LEN;
+ if (start < str.length()) {
+ end = str.indexOf(CDATA_END, start);
+ } else {
+ return;
+ }
+ }
+ buf.append(str.substring(start));
+ }
+ }
+ }
+}
diff --git a/src/java/org/apache/log4j/helpers/package.html b/src/main/java/org/apache/log4j/helpers/package.html
similarity index 100%
rename from src/java/org/apache/log4j/helpers/package.html
rename to src/main/java/org/apache/log4j/helpers/package.html
diff --git a/src/java/org/apache/log4j/jdbc/JDBCAppender.java b/src/main/java/org/apache/log4j/jdbc/JDBCAppender.java
similarity index 86%
rename from src/java/org/apache/log4j/jdbc/JDBCAppender.java
rename to src/main/java/org/apache/log4j/jdbc/JDBCAppender.java
index 31bf000291..eca1a3821f 100644
--- a/src/java/org/apache/log4j/jdbc/JDBCAppender.java
+++ b/src/main/java/org/apache/log4j/jdbc/JDBCAppender.java
@@ -1,6 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.jdbc;
-import org.apache.log4j.*;
import org.apache.log4j.spi.*;
import org.apache.log4j.PatternLayout;
@@ -14,8 +29,13 @@
/**
- The JDBCAppender provides for sending log events to a database.
+ ArrayList buffer. When
the buffer is filled each log event is placed in a sql statement
(configurable) and executed.
@@ -53,7 +73,7 @@
- @author: Kevin Steppe (ksteppe@pacbell.net)
+ @author Kevin Steppe (ksteppe@pacbell.net)
*/
public class JDBCAppender extends org.apache.log4j.AppenderSkeleton
@@ -86,7 +106,7 @@ public class JDBCAppender extends org.apache.log4j.AppenderSkeleton
/**
* Stores the string given to the pattern layout for conversion into a SQL
* statement, eg: insert into LogTable (Thread, Class, Message) values
- * ("%t", "%c", "%m")
+ * ("%t", "%c", "%m").
*
* Be careful of quotes in your messages!
*
@@ -235,8 +255,12 @@ public void flushBuffer() {
ErrorCode.FLUSH_FAILURE);
}
}
+
+ // remove from the buffer any events that were reported
buffer.removeAll(removes);
- //buffer.clear();
+
+ // clear the buffer of reported events
+ removes.clear();
}
@@ -247,10 +271,10 @@ public void finalize() {
/**
- * JDBCAppender builds a layout internally if one is not provided.
- */
+ * JDBCAppender requires a layout.
+ * */
public boolean requiresLayout() {
- return false;
+ return true;
}
diff --git a/src/java/org/apache/log4j/jdbc/package.html b/src/main/java/org/apache/log4j/jdbc/package.html
similarity index 100%
rename from src/java/org/apache/log4j/jdbc/package.html
rename to src/main/java/org/apache/log4j/jdbc/package.html
diff --git a/src/java/org/apache/log4j/jmx/AbstractDynamicMBean.java b/src/main/java/org/apache/log4j/jmx/AbstractDynamicMBean.java
similarity index 79%
rename from src/java/org/apache/log4j/jmx/AbstractDynamicMBean.java
rename to src/main/java/org/apache/log4j/jmx/AbstractDynamicMBean.java
index a9601e7ff2..b2674f5106 100644
--- a/src/java/org/apache/log4j/jmx/AbstractDynamicMBean.java
+++ b/src/main/java/org/apache/log4j/jmx/AbstractDynamicMBean.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.jmx;
diff --git a/src/main/java/org/apache/log4j/jmx/Agent.java b/src/main/java/org/apache/log4j/jmx/Agent.java
new file mode 100644
index 0000000000..835af8f71a
--- /dev/null
+++ b/src/main/java/org/apache/log4j/jmx/Agent.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.jmx;
+
+import javax.management.ObjectName;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import com.sun.jdmk.comm.HtmlAdaptorServer;
+
+import org.apache.log4j.Logger;
+
+
+public class Agent {
+
+ static Logger log = Logger.getLogger(Agent.class);
+
+ public Agent() {
+ }
+
+
+ public
+ void start() {
+
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ HtmlAdaptorServer html = new HtmlAdaptorServer();
+
+ try {
+ log.info("Registering HtmlAdaptorServer instance.");
+ server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
+ log.info("Registering HierarchyDynamicMBean instance.");
+ HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
+ server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
+
+ } catch(Exception e) {
+ log.error("Problem while regitering MBeans instances.", e);
+ return;
+ }
+ html.start();
+ }
+}
diff --git a/src/java/org/apache/log4j/jmx/AppenderDynamicMBean.java b/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java
similarity index 88%
rename from src/java/org/apache/log4j/jmx/AppenderDynamicMBean.java
rename to src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java
index 2b2aab0b45..55e38845a2 100644
--- a/src/java/org/apache/log4j/jmx/AppenderDynamicMBean.java
+++ b/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.jmx;
@@ -183,14 +193,11 @@ void registerLayoutMBean(Layout layout) {
try {
LayoutDynamicMBean appenderMBean = new LayoutDynamicMBean(layout);
objectName = new ObjectName("log4j:appender="+name);
- server.registerMBean(appenderMBean, objectName);
-
- dAttributes.add(new MBeanAttributeInfo("appender="+name,
- "javax.management.ObjectName",
- "The "+name+" layout.",
- true,
- true,
- false));
+ if (!server.isRegistered(objectName)) {
+ server.registerMBean(appenderMBean, objectName);
+ dAttributes.add(new MBeanAttributeInfo("appender=" + name, "javax.management.ObjectName",
+ "The " + name + " layout.", true, true, false));
+ }
} catch(Exception e) {
cat.error("Could not add DynamicLayoutMBean for ["+name+"].", e);
diff --git a/src/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java b/src/main/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java
similarity index 84%
rename from src/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java
rename to src/main/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java
index 361409b90a..66492e1698 100644
--- a/src/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java
+++ b/src/main/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.jmx;
@@ -93,7 +103,7 @@ void buildDynamicMBeanInfo() {
public
ObjectName addLoggerMBean(String name) {
- Logger cat = Logger.exists(name);
+ Logger cat = LogManager.exists(name);
if(cat != null) {
return addLoggerMBean(cat);
@@ -108,26 +118,22 @@ ObjectName addLoggerMBean(Logger logger) {
try {
LoggerDynamicMBean loggerMBean = new LoggerDynamicMBean(logger);
objectName = new ObjectName("log4j", "logger", name);
- server.registerMBean(loggerMBean, objectName);
-
- NotificationFilterSupport nfs = new NotificationFilterSupport();
- nfs.enableType(ADD_APPENDER+logger.getName());
-
- log.debug("---Adding logger ["+name+"] as listener.");
-
- nbs.addNotificationListener(loggerMBean, nfs, null);
-
-
- vAttributes.add(new MBeanAttributeInfo("logger="+name,
- "javax.management.ObjectName",
- "The "+name+" logger.",
- true,
- true, // this makes the object
- // clickable
- false));
+
+ if (!server.isRegistered(objectName)) {
+ server.registerMBean(loggerMBean, objectName);
+ NotificationFilterSupport nfs = new NotificationFilterSupport();
+ nfs.enableType(ADD_APPENDER + logger.getName());
+ log.debug("---Adding logger [" + name + "] as listener.");
+ nbs.addNotificationListener(loggerMBean, nfs, null);
+ vAttributes.add(new MBeanAttributeInfo("logger=" + name, "javax.management.ObjectName",
+ "The " + name + " logger.", true, true, // this makes the object
+ // clickable
+ false));
+
+ }
} catch(Exception e) {
- log.error("Couls not add loggerMBean for ["+name+"].");
+ log.error("Could not add loggerMBean for ["+name+"].", e);
}
return objectName;
}
diff --git a/src/java/org/apache/log4j/jmx/LayoutDynamicMBean.java b/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java
similarity index 89%
rename from src/java/org/apache/log4j/jmx/LayoutDynamicMBean.java
rename to src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java
index d9f4ac5f4d..022b9f4152 100644
--- a/src/java/org/apache/log4j/jmx/LayoutDynamicMBean.java
+++ b/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.jmx;
diff --git a/src/java/org/apache/log4j/jmx/LoggerDynamicMBean.java b/src/main/java/org/apache/log4j/jmx/LoggerDynamicMBean.java
similarity index 85%
rename from src/java/org/apache/log4j/jmx/LoggerDynamicMBean.java
rename to src/main/java/org/apache/log4j/jmx/LoggerDynamicMBean.java
index 086f99c0b2..f97d948a93 100644
--- a/src/java/org/apache/log4j/jmx/LoggerDynamicMBean.java
+++ b/src/main/java/org/apache/log4j/jmx/LoggerDynamicMBean.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.jmx;
@@ -218,7 +234,7 @@ void setAttribute(Attribute attribute) throws AttributeNotFoundException,
} else {
p = OptionConverter.toLevel(s, p);
}
- logger.setPriority(p);
+ logger.setLevel(p);
}
} else {
throw(new AttributeNotFoundException("Attribute " + name +
@@ -228,9 +244,9 @@ void setAttribute(Attribute attribute) throws AttributeNotFoundException,
}
void appenderMBeanRegistration() {
- Enumeration enum = logger.getAllAppenders();
- while(enum.hasMoreElements()) {
- Appender appender = (Appender) enum.nextElement();
+ Enumeration enumeration = logger.getAllAppenders();
+ while(enumeration.hasMoreElements()) {
+ Appender appender = (Appender) enumeration.nextElement();
registerAppenderMBean(appender);
}
}
@@ -242,14 +258,11 @@ void registerAppenderMBean(Appender appender) {
try {
AppenderDynamicMBean appenderMBean = new AppenderDynamicMBean(appender);
objectName = new ObjectName("log4j", "appender", name);
- server.registerMBean(appenderMBean, objectName);
-
- dAttributes.add(new MBeanAttributeInfo("appender="+name,
- "javax.management.ObjectName",
- "The "+name+" appender.",
- true,
- true,
- false));
+ if (!server.isRegistered(objectName)) {
+ server.registerMBean(appenderMBean, objectName);
+ dAttributes.add(new MBeanAttributeInfo("appender=" + name, "javax.management.ObjectName",
+ "The " + name + " appender.", true, true, false));
+ }
} catch(Exception e) {
cat.error("Could not add appenderMBean for ["+name+"].", e);
diff --git a/src/main/java/org/apache/log4j/jmx/MethodUnion.java b/src/main/java/org/apache/log4j/jmx/MethodUnion.java
new file mode 100644
index 0000000000..e9f2fb2c52
--- /dev/null
+++ b/src/main/java/org/apache/log4j/jmx/MethodUnion.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.jmx;
+
+import java.lang.reflect.Method;
+
+class MethodUnion {
+
+ Method readMethod;
+ Method writeMethod;
+
+ MethodUnion( Method readMethod, Method writeMethod) {
+ this.readMethod = readMethod;
+ this.writeMethod = writeMethod;
+ }
+
+}
diff --git a/src/java/org/apache/log4j/jmx/package.html b/src/main/java/org/apache/log4j/jmx/package.html
similarity index 100%
rename from src/java/org/apache/log4j/jmx/package.html
rename to src/main/java/org/apache/log4j/jmx/package.html
diff --git a/src/java/org/apache/log4j/lf5/AppenderFinalizer.java b/src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java
similarity index 74%
rename from src/java/org/apache/log4j/lf5/AppenderFinalizer.java
rename to src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java
index a948b2fbc0..a2a7019208 100644
--- a/src/java/org/apache/log4j/lf5/AppenderFinalizer.java
+++ b/src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5;
diff --git a/src/java/org/apache/log4j/lf5/DefaultLF5Configurator.java b/src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.java
similarity index 81%
rename from src/java/org/apache/log4j/lf5/DefaultLF5Configurator.java
rename to src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.java
index 5932744712..31d7f5bfc5 100644
--- a/src/java/org/apache/log4j/lf5/DefaultLF5Configurator.java
+++ b/src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5;
diff --git a/src/java/org/apache/log4j/lf5/LF5Appender.java b/src/main/java/org/apache/log4j/lf5/LF5Appender.java
similarity index 90%
rename from src/java/org/apache/log4j/lf5/LF5Appender.java
rename to src/main/java/org/apache/log4j/lf5/LF5Appender.java
index 444b76e136..a577a4c330 100644
--- a/src/java/org/apache/log4j/lf5/LF5Appender.java
+++ b/src/main/java/org/apache/log4j/lf5/LF5Appender.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5;
@@ -88,11 +97,11 @@ public LF5Appender(LogBrokerMonitor monitor) {
*/
public void append(LoggingEvent event) {
// Retrieve the information from the log4j LoggingEvent.
- String category = event.categoryName;
+ String category = event.getLoggerName();
String logMessage = event.getRenderedMessage();
String nestedDiagnosticContext = event.getNDC();
String threadDescription = event.getThreadName();
- String level = event.level.toString();
+ String level = event.getLevel().toString();
long time = event.timeStamp;
LocationInfo locationInfo = event.getLocationInformation();
@@ -255,4 +264,4 @@ protected static int getDefaultMonitorHeight() {
// Nested Top-Level Classes or Interfaces:
//--------------------------------------------------------------------------
-}
\ No newline at end of file
+}
diff --git a/src/java/org/apache/log4j/lf5/Log4JLogRecord.java b/src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java
similarity index 80%
rename from src/java/org/apache/log4j/lf5/Log4JLogRecord.java
rename to src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java
index 1df491e5af..4393eb586d 100644
--- a/src/java/org/apache/log4j/lf5/Log4JLogRecord.java
+++ b/src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5;
diff --git a/src/java/org/apache/log4j/lf5/LogLevel.java b/src/main/java/org/apache/log4j/lf5/LogLevel.java
similarity index 90%
rename from src/java/org/apache/log4j/lf5/LogLevel.java
rename to src/main/java/org/apache/log4j/lf5/LogLevel.java
index 82074f1230..b168cc9cf0 100644
--- a/src/java/org/apache/log4j/lf5/LogLevel.java
+++ b/src/main/java/org/apache/log4j/lf5/LogLevel.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5;
diff --git a/src/java/org/apache/log4j/lf5/LogLevelFormatException.java b/src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java
similarity index 70%
rename from src/java/org/apache/log4j/lf5/LogLevelFormatException.java
rename to src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java
index 384b829f51..1109e23836 100644
--- a/src/java/org/apache/log4j/lf5/LogLevelFormatException.java
+++ b/src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5;
diff --git a/src/java/org/apache/log4j/lf5/LogRecord.java b/src/main/java/org/apache/log4j/lf5/LogRecord.java
similarity index 92%
rename from src/java/org/apache/log4j/lf5/LogRecord.java
rename to src/main/java/org/apache/log4j/lf5/LogRecord.java
index 8d1cfa4a7a..4f4097f20a 100644
--- a/src/java/org/apache/log4j/lf5/LogRecord.java
+++ b/src/main/java/org/apache/log4j/lf5/LogRecord.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5;
@@ -350,7 +359,7 @@ public String getLocation() {
/**
* Set the location in code where this LogRecord originated.
*
- * @param ndc A string containing location information.
+ * @param location A string containing location information.
*/
public void setLocation(String location) {
_location = location;
diff --git a/src/java/org/apache/log4j/lf5/LogRecordFilter.java b/src/main/java/org/apache/log4j/lf5/LogRecordFilter.java
similarity index 50%
rename from src/java/org/apache/log4j/lf5/LogRecordFilter.java
rename to src/main/java/org/apache/log4j/lf5/LogRecordFilter.java
index 51fb78ee3e..25a3e53c2e 100644
--- a/src/java/org/apache/log4j/lf5/LogRecordFilter.java
+++ b/src/main/java/org/apache/log4j/lf5/LogRecordFilter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5;
diff --git a/src/java/org/apache/log4j/lf5/PassingLogRecordFilter.java b/src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java
similarity index 70%
rename from src/java/org/apache/log4j/lf5/PassingLogRecordFilter.java
rename to src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java
index 6424a0e2f1..178f6cb67c 100644
--- a/src/java/org/apache/log4j/lf5/PassingLogRecordFilter.java
+++ b/src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5;
diff --git a/src/java/org/apache/log4j/lf5/StartLogFactor5.java b/src/main/java/org/apache/log4j/lf5/StartLogFactor5.java
similarity index 73%
rename from src/java/org/apache/log4j/lf5/StartLogFactor5.java
rename to src/main/java/org/apache/log4j/lf5/StartLogFactor5.java
index 45d09e873e..1ea28c3c72 100644
--- a/src/java/org/apache/log4j/lf5/StartLogFactor5.java
+++ b/src/main/java/org/apache/log4j/lf5/StartLogFactor5.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5;
diff --git a/src/java/org/apache/log4j/lf5/util/AdapterLogRecord.java b/src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java
similarity index 79%
rename from src/java/org/apache/log4j/lf5/util/AdapterLogRecord.java
rename to src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java
index 6a834a7b61..2e4ee6f02f 100644
--- a/src/java/org/apache/log4j/lf5/util/AdapterLogRecord.java
+++ b/src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.util;
diff --git a/src/java/org/apache/log4j/lf5/util/DateFormatManager.java b/src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java
similarity index 87%
rename from src/java/org/apache/log4j/lf5/util/DateFormatManager.java
rename to src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java
index 18c7beba10..6bed9cc862 100644
--- a/src/java/org/apache/log4j/lf5/util/DateFormatManager.java
+++ b/src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.util;
@@ -119,7 +128,7 @@ public synchronized TimeZone getTimeZone() {
}
public synchronized void setTimeZone(TimeZone timeZone) {
- timeZone = timeZone;
+ _timeZone = timeZone;
configure();
}
diff --git a/src/java/org/apache/log4j/lf5/util/LogFileParser.java b/src/main/java/org/apache/log4j/lf5/util/LogFileParser.java
similarity index 90%
rename from src/java/org/apache/log4j/lf5/util/LogFileParser.java
rename to src/main/java/org/apache/log4j/lf5/util/LogFileParser.java
index 79bf721979..9fd1317d41 100644
--- a/src/java/org/apache/log4j/lf5/util/LogFileParser.java
+++ b/src/main/java/org/apache/log4j/lf5/util/LogFileParser.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.util;
diff --git a/src/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java b/src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java
similarity index 91%
rename from src/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java
rename to src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java
index 1e568e51b0..904c179dd3 100644
--- a/src/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java
+++ b/src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.util;
diff --git a/src/java/org/apache/log4j/lf5/util/Resource.java b/src/main/java/org/apache/log4j/lf5/util/Resource.java
similarity index 81%
rename from src/java/org/apache/log4j/lf5/util/Resource.java
rename to src/main/java/org/apache/log4j/lf5/util/Resource.java
index 6ae81cfe67..66293cfcab 100644
--- a/src/java/org/apache/log4j/lf5/util/Resource.java
+++ b/src/main/java/org/apache/log4j/lf5/util/Resource.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.util;
diff --git a/src/java/org/apache/log4j/lf5/util/ResourceUtils.java b/src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java
similarity index 82%
rename from src/java/org/apache/log4j/lf5/util/ResourceUtils.java
rename to src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java
index 9c7ec62e1c..5f022b6729 100644
--- a/src/java/org/apache/log4j/lf5/util/ResourceUtils.java
+++ b/src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.util;
diff --git a/src/java/org/apache/log4j/lf5/util/StreamUtils.java b/src/main/java/org/apache/log4j/lf5/util/StreamUtils.java
similarity index 80%
rename from src/java/org/apache/log4j/lf5/util/StreamUtils.java
rename to src/main/java/org/apache/log4j/lf5/util/StreamUtils.java
index d9e0a3dbcf..0d673583ab 100644
--- a/src/java/org/apache/log4j/lf5/util/StreamUtils.java
+++ b/src/main/java/org/apache/log4j/lf5/util/StreamUtils.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.util;
diff --git a/src/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java b/src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java
similarity index 89%
rename from src/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java
rename to src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java
index f77a5bb4de..2c68180975 100644
--- a/src/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java b/src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java
similarity index 84%
rename from src/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java
index 14c953a4d4..a00f2c30f5 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java b/src/main/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java
similarity index 97%
rename from src/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java
index 5eacbedb35..550a7b93ed 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
@@ -12,7 +21,6 @@
import org.apache.log4j.lf5.LogRecordFilter;
import org.apache.log4j.lf5.util.DateFormatManager;
import org.apache.log4j.lf5.util.LogFileParser;
-import org.apache.log4j.lf5.util.ProductProperties;
import org.apache.log4j.lf5.util.StreamUtils;
import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryExplorerTree;
import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryPath;
@@ -475,8 +483,6 @@ protected void initComponents() {
//
// Configure the Frame.
//
- ProductProperties props = ProductProperties.getInstance();
-
_logMonitorFrame = new JFrame("LogFactor5");
_logMonitorFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
@@ -1070,8 +1076,6 @@ protected JMenu createHelpMenu() {
JMenu helpMenu = new JMenu("Help");
helpMenu.setMnemonic('h');
helpMenu.add(createHelpProperties());
- helpMenu.addSeparator();
- helpMenu.add(createHelpAbout());
return helpMenu;
}
@@ -1096,25 +1100,6 @@ protected void showPropertiesDialog(String title) {
);
}
- protected JMenuItem createHelpAbout() {
- JMenuItem aboutMI = new JMenuItem("About LogFactor5...");
- aboutMI.setMnemonic('a');
- //aboutMI.setAccelerator( KeyStroke.getKeyStroke("control A") );
-
- aboutMI.addActionListener(
- new ActionListener() {
- protected LogFactor5AboutDialog dialog =
- new LogFactor5AboutDialog(_logMonitorFrame);
-
- public void actionPerformed(ActionEvent e) {
- dialog.show();
- }
- }
-
- );
- return aboutMI;
- }
-
protected JMenu createEditMenu() {
JMenu editMenu = new JMenu("Edit");
editMenu.setMnemonic('e');
@@ -1216,7 +1201,10 @@ protected JToolBar createToolBar() {
_fontSizeCombo = fontSizeCombo;
ClassLoader cl = this.getClass().getClassLoader();
- URL newIconURL = cl.getResource("org/apache/log4j/viewer/" +
+ if(cl == null) {
+ cl = ClassLoader.getSystemClassLoader();
+ }
+ URL newIconURL = cl.getResource("org/apache/log4j/lf5/viewer/" +
"images/channelexplorer_new.gif");
ImageIcon newIcon = null;
diff --git a/src/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java
similarity index 84%
rename from src/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java
index 0e5949e72c..bb203172d9 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java
similarity index 75%
rename from src/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java
index c0cb85b156..41ef07528a 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java
similarity index 83%
rename from src/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java
index 8831d7e432..890e6dbfea 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java
similarity index 73%
rename from src/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java
index 4ec70e2e61..a08bf329bd 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/LogTable.java b/src/main/java/org/apache/log4j/lf5/viewer/LogTable.java
similarity index 89%
rename from src/java/org/apache/log4j/lf5/viewer/LogTable.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LogTable.java
index 7f108516c5..2198403738 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LogTable.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LogTable.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
@@ -32,6 +41,7 @@
// Contributed by ThoughtWorks Inc.
public class LogTable extends JTable {
+ private static final long serialVersionUID = 4867085140195148458L;
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
diff --git a/src/java/org/apache/log4j/lf5/viewer/LogTableColumn.java b/src/main/java/org/apache/log4j/lf5/viewer/LogTableColumn.java
similarity index 84%
rename from src/java/org/apache/log4j/lf5/viewer/LogTableColumn.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LogTableColumn.java
index 8a17b3df73..045212cd5b 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LogTableColumn.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LogTableColumn.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
@@ -22,6 +31,7 @@
// Contributed by ThoughtWorks Inc.
public class LogTableColumn implements java.io.Serializable {
+ private static final long serialVersionUID = -4275827753626456547L;
// log4j table columns.
public final static LogTableColumn DATE = new LogTableColumn("Date");
diff --git a/src/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java b/src/main/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java
similarity index 68%
rename from src/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java
index 5ccd95433c..b161fe7bcb 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
@@ -18,6 +27,7 @@
// Contributed by ThoughtWorks Inc.
public class LogTableColumnFormatException extends Exception {
+ private static final long serialVersionUID = 6529165785030431653L;
//--------------------------------------------------------------------------
// Constants:
diff --git a/src/java/org/apache/log4j/lf5/viewer/LogTableModel.java b/src/main/java/org/apache/log4j/lf5/viewer/LogTableModel.java
similarity index 68%
rename from src/java/org/apache/log4j/lf5/viewer/LogTableModel.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LogTableModel.java
index f48c0b4dbd..3b60000bfc 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LogTableModel.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LogTableModel.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
@@ -19,6 +28,7 @@
// Contributed by ThoughtWorks Inc.
public class LogTableModel extends DefaultTableModel {
+ private static final long serialVersionUID = 3593300685868700894L;
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
diff --git a/src/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java b/src/main/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java
similarity index 75%
rename from src/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java
rename to src/main/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java
index 1947977a82..648b25d14c 100644
--- a/src/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
@@ -25,6 +34,7 @@
// Contributed by ThoughtWorks Inc.
public class LogTableRowRenderer extends DefaultTableCellRenderer {
+ private static final long serialVersionUID = -3951639953706443213L;
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
diff --git a/src/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java b/src/main/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java
similarity index 77%
rename from src/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java
rename to src/main/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java
index 8c14c79740..8d1408ffc9 100644
--- a/src/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java
similarity index 85%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java
index 47c20a5ab4..f3fc522fea 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java
similarity index 71%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java
index 54dc31a127..1391fd574a 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java
similarity index 78%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java
index 2b1b52e923..63f91aef2d 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java
similarity index 91%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java
index 9d0c3fa364..67354690fe 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
@@ -30,6 +39,8 @@
// Contributed by ThoughtWorks Inc.
public class CategoryExplorerModel extends DefaultTreeModel {
+ private static final long serialVersionUID = -3413887384316015901L;
+
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java
similarity index 81%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java
index a607cca3da..b8416827eb 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
@@ -24,6 +33,7 @@
// Contributed by ThoughtWorks Inc.
public class CategoryExplorerTree extends JTree {
+ private static final long serialVersionUID = 8066257446951323576L;
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java
similarity index 82%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java
index 25a63e77ab..f5bbfb3854 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java
similarity index 84%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java
index bc7b4a25d0..95bdc4280b 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
@@ -21,6 +30,7 @@
// Contributed by ThoughtWorks Inc.
public class CategoryNode extends DefaultMutableTreeNode {
+ private static final long serialVersionUID = 5958994817693177319L;
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java
similarity index 89%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java
index fbb6a9bfb6..a4a9bdc99e 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
@@ -241,9 +250,9 @@ protected void collapseDescendants(CategoryNode node) {
protected int removeUnusedNodes() {
int count = 0;
CategoryNode root = _categoryModel.getRootCategoryNode();
- Enumeration enum = root.depthFirstEnumeration();
- while (enum.hasMoreElements()) {
- CategoryNode node = (CategoryNode) enum.nextElement();
+ Enumeration enumeration = root.depthFirstEnumeration();
+ while (enumeration.hasMoreElements()) {
+ CategoryNode node = (CategoryNode) enumeration.nextElement();
if (node.isLeaf() && node.getNumberOfContainedRecords() == 0
&& node.getParent() != null) {
_categoryModel.removeNodeFromParent(node);
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java
similarity index 71%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java
index 0b901cd624..d439990850 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
@@ -20,6 +29,8 @@
// Contributed by ThoughtWorks Inc.
public class CategoryNodeEditorRenderer extends CategoryNodeRenderer {
+ private static final long serialVersionUID = -6094804684259929574L;
+
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java
similarity index 82%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java
index 4de68fffd9..4eb461dd43 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
@@ -22,6 +31,8 @@
// Contributed by ThoughtWorks Inc.
public class CategoryNodeRenderer extends DefaultTreeCellRenderer {
+ private static final long serialVersionUID = -6046702673278595048L;
+
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java
similarity index 83%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java
index f044c16f7c..3863c0b8b2 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java
similarity index 72%
rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java
rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java
index 4d548d4a28..7323dcc08e 100644
--- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.categoryexplorer;
diff --git a/src/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java b/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java
similarity index 94%
rename from src/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java
rename to src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java
index 3e389d8d5a..2f9f95f005 100644
--- a/src/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.configure;
@@ -57,7 +66,6 @@ public class ConfigurationManager extends Object {
private static final String FIRST_CATEGORY_NAME = "Categories";
private static final String LEVEL = "level";
private static final String COLORLEVEL = "colorlevel";
- private static final String COLOR = "color";
private static final String RED = "red";
private static final String GREEN = "green";
private static final String BLUE = "blue";
@@ -216,7 +224,7 @@ protected void processLogLevels(Document doc) {
protected void processLogLevelColors(Document doc) {
NodeList nodeList = doc.getElementsByTagName(COLORLEVEL);
- Map logLevelColors = LogLevel.getLogLevelColorMap();
+ LogLevel.getLogLevelColorMap();
for (int i = 0; i < nodeList.getLength(); i++) {
Node n = nodeList.item(i);
@@ -330,8 +338,7 @@ protected void deleteConfigurationFile() {
protected String getFilename() {
String home = System.getProperty("user.home");
- String sep = (home.startsWith(MRUFileManager.UNIX_SEPARATOR))
- ? MRUFileManager.UNIX_SEPARATOR : MRUFileManager.DOS_SEPARATOR;
+ String sep = System.getProperty("file.separator");
return home + sep + "lf5" + sep + CONFIG_FILE_NAME;
}
diff --git a/src/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java b/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java
similarity index 87%
rename from src/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java
rename to src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java
index 5163a073cd..8c10ee28a1 100644
--- a/src/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java
+++ b/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.lf5.viewer.configure;
@@ -29,8 +38,6 @@ public class MRUFileManager {
//--------------------------------------------------------------------------
private static final String CONFIG_FILE_NAME = "mru_file_manager";
private static final int DEFAULT_MAX_SIZE = 3;
- public static final String UNIX_SEPARATOR = "/";
- public static final String DOS_SEPARATOR = "\\";
//--------------------------------------------------------------------------
// Protected Variables:
@@ -74,7 +81,6 @@ public void save() {
// do nothing
e.printStackTrace();
}
-
}
/**
@@ -112,7 +118,6 @@ public InputStream getInputStream(int index) throws IOException,
return null;
}
-
/**
* Adds a file name to the MRU file list.
*/
@@ -168,7 +173,7 @@ public void moveToTop(int index) {
*/
public static void createConfigurationDirectory() {
String home = System.getProperty("user.home");
- String sep = (home.startsWith(UNIX_SEPARATOR)) ? UNIX_SEPARATOR : DOS_SEPARATOR;
+ String sep = System.getProperty("file.separator");
File f = new File(home + sep + "lf5");
if (!f.exists()) {
try {
@@ -253,7 +258,7 @@ protected void load() {
protected String getFilename() {
String home = System.getProperty("user.home");
- String sep = (home.startsWith(UNIX_SEPARATOR)) ? UNIX_SEPARATOR : DOS_SEPARATOR;
+ String sep = System.getProperty("file.separator");
return home + sep + "lf5" + sep + CONFIG_FILE_NAME;
}
@@ -264,7 +269,7 @@ protected String getFilename() {
protected void setMaxSize(int maxSize) {
if (maxSize < _mruFileList.size()) {
for (int i = 0; i < _mruFileList.size() - maxSize; i++) {
- _mruFileList.removeFirst();
+ _mruFileList.removeLast();
}
}
diff --git a/src/main/java/org/apache/log4j/net/JMSAppender.java b/src/main/java/org/apache/log4j/net/JMSAppender.java
new file mode 100644
index 0000000000..dd11a91b35
--- /dev/null
+++ b/src/main/java/org/apache/log4j/net/JMSAppender.java
@@ -0,0 +1,432 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.net;
+
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.ErrorCode;
+import org.apache.log4j.helpers.LogLog;
+
+import java.util.Properties;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.Topic;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
+import javax.jms.Session;
+import javax.jms.ObjectMessage;
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+/**
+ * A simple appender that publishes events to a JMS Topic. The events
+ * are serialized and transmitted as JMS message type {@link
+ * ObjectMessage}.
+
+ *
+ InitialContext jndiContext = new InitialContext();
+
+
+ * InitialContext() method
+ * will also work from within Enterprise Java Beans (EJBs) because it
+ * is part of the EJB contract for application servers to provide each
+ * bean an environment naming context (ENC).
+
+ * InitialContext
+ * contructor to connect to the naming service provider. For example,
+ * to connect to JBoss naming service one would write:
+
+
+ Properties env = new Properties( );
+ env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ env.put(Context.PROVIDER_URL, "jnp://hostname:1099");
+ env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
+ InitialContext jndiContext = new InitialContext(env);
+
+
+ * where hostname is the host where the JBoss applicaiton
+ * server is running.
+ *
+ *
+ Properties env = new Properties( );
+ env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
+ env.put(Context.PROVIDER_URL, "t3://localhost:7001");
+ InitialContext jndiContext = new InitialContext(env);
+
+
+ * InitialContext() method in EJBs. Only
+ * clients running in a separate JVM need to be concerned about the
+ * jndi.properties file and calling {@link
+ * InitialContext#InitialContext()} or alternatively correctly
+ * setting the different properties before calling {@link
+ * InitialContext#InitialContext(java.util.Hashtable)} method.
+
+
+ @author Ceki Gülcü */
+public class JMSAppender extends AppenderSkeleton {
+
+ String securityPrincipalName;
+ String securityCredentials;
+ String initialContextFactoryName;
+ String urlPkgPrefixes;
+ String providerURL;
+ String topicBindingName;
+ String tcfBindingName;
+ String userName;
+ String password;
+ boolean locationInfo;
+
+ TopicConnection topicConnection;
+ TopicSession topicSession;
+ TopicPublisher topicPublisher;
+
+ public
+ JMSAppender() {
+ }
+
+ /**
+ The TopicConnectionFactoryBindingName option takes a
+ string value. Its value will be used to lookup the appropriate
+ TopicConnectionFactory from the JNDI context.
+ */
+ public
+ void setTopicConnectionFactoryBindingName(String tcfBindingName) {
+ this.tcfBindingName = tcfBindingName;
+ }
+
+ /**
+ Returns the value of the TopicConnectionFactoryBindingName option.
+ */
+ public
+ String getTopicConnectionFactoryBindingName() {
+ return tcfBindingName;
+ }
+
+ /**
+ The TopicBindingName option takes a
+ string value. Its value will be used to lookup the appropriate
+ Topic from the JNDI context.
+ */
+ public
+ void setTopicBindingName(String topicBindingName) {
+ this.topicBindingName = topicBindingName;
+ }
+
+ /**
+ Returns the value of the TopicBindingName option.
+ */
+ public
+ String getTopicBindingName() {
+ return topicBindingName;
+ }
+
+
+ /**
+ Returns value of the LocationInfo property which
+ determines whether location (stack) info is sent to the remote
+ subscriber. */
+ public
+ boolean getLocationInfo() {
+ return locationInfo;
+ }
+
+ /**
+ * Options are activated and become effective only after calling
+ * this method.*/
+ public void activateOptions() {
+ TopicConnectionFactory topicConnectionFactory;
+
+ try {
+ Context jndi;
+
+ LogLog.debug("Getting initial context.");
+ if(initialContextFactoryName != null) {
+ Properties env = new Properties( );
+ env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactoryName);
+ if(providerURL != null) {
+ env.put(Context.PROVIDER_URL, providerURL);
+ } else {
+ LogLog.warn("You have set InitialContextFactoryName option but not the "
+ +"ProviderURL. This is likely to cause problems.");
+ }
+ if(urlPkgPrefixes != null) {
+ env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes);
+ }
+
+ if(securityPrincipalName != null) {
+ env.put(Context.SECURITY_PRINCIPAL, securityPrincipalName);
+ if(securityCredentials != null) {
+ env.put(Context.SECURITY_CREDENTIALS, securityCredentials);
+ } else {
+ LogLog.warn("You have set SecurityPrincipalName option but not the "
+ +"SecurityCredentials. This is likely to cause problems.");
+ }
+ }
+ jndi = new InitialContext(env);
+ } else {
+ jndi = new InitialContext();
+ }
+
+ LogLog.debug("Looking up ["+tcfBindingName+"]");
+ topicConnectionFactory = (TopicConnectionFactory) lookup(jndi, tcfBindingName);
+ LogLog.debug("About to create TopicConnection.");
+ if(userName != null) {
+ topicConnection = topicConnectionFactory.createTopicConnection(userName,
+ password);
+ } else {
+ topicConnection = topicConnectionFactory.createTopicConnection();
+ }
+
+ LogLog.debug("Creating TopicSession, non-transactional, "
+ +"in AUTO_ACKNOWLEDGE mode.");
+ topicSession = topicConnection.createTopicSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+
+ LogLog.debug("Looking up topic name ["+topicBindingName+"].");
+ Topic topic = (Topic) lookup(jndi, topicBindingName);
+
+ LogLog.debug("Creating TopicPublisher.");
+ topicPublisher = topicSession.createPublisher(topic);
+
+ LogLog.debug("Starting TopicConnection.");
+ topicConnection.start();
+
+ jndi.close();
+ } catch(Exception e) {
+ errorHandler.error("Error while activating options for appender named ["+name+
+ "].", e, ErrorCode.GENERIC_FAILURE);
+ }
+ }
+
+ protected Object lookup(Context ctx, String name) throws NamingException {
+ try {
+ return ctx.lookup(name);
+ } catch(NameNotFoundException e) {
+ LogLog.error("Could not find name ["+name+"].");
+ throw e;
+ }
+ }
+
+ protected boolean checkEntryConditions() {
+ String fail = null;
+
+ if(this.topicConnection == null) {
+ fail = "No TopicConnection";
+ } else if(this.topicSession == null) {
+ fail = "No TopicSession";
+ } else if(this.topicPublisher == null) {
+ fail = "No TopicPublisher";
+ }
+
+ if(fail != null) {
+ errorHandler.error(fail +" for JMSAppender named ["+name+"].");
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ Close this JMSAppender. Closing releases all resources used by the
+ appender. A closed appender cannot be re-opened. */
+ public synchronized void close() {
+ // The synchronized modifier avoids concurrent append and close operations
+
+ if(this.closed)
+ return;
+
+ LogLog.debug("Closing appender ["+name+"].");
+ this.closed = true;
+
+ try {
+ if(topicSession != null)
+ topicSession.close();
+ if(topicConnection != null)
+ topicConnection.close();
+ } catch(Exception e) {
+ LogLog.error("Error while closing JMSAppender ["+name+"].", e);
+ }
+ // Help garbage collection
+ topicPublisher = null;
+ topicSession = null;
+ topicConnection = null;
+ }
+
+ /**
+ This method called by {@link AppenderSkeleton#doAppend} method to
+ do most of the real appending work. */
+ public void append(LoggingEvent event) {
+ if(!checkEntryConditions()) {
+ return;
+ }
+
+ try {
+ ObjectMessage msg = topicSession.createObjectMessage();
+ if(locationInfo) {
+ event.getLocationInformation();
+ }
+ msg.setObject(event);
+ topicPublisher.publish(msg);
+ } catch(Exception e) {
+ errorHandler.error("Could not publish message in JMSAppender ["+name+"].", e,
+ ErrorCode.GENERIC_FAILURE);
+ }
+ }
+
+ /**
+ * Returns the value of the InitialContextFactoryName option.
+ * See {@link #setInitialContextFactoryName} for more details on the
+ * meaning of this option.
+ * */
+ public String getInitialContextFactoryName() {
+ return initialContextFactoryName;
+ }
+
+ /**
+ * Setting the InitialContextFactoryName method will cause
+ * this JMSAppender instance to use the {@link
+ * InitialContext#InitialContext(Hashtable)} method instead of the
+ * no-argument constructor. If you set this option, you should also
+ * at least set the ProviderURL option.
+ *
+ * false. */
public
boolean isTriggeringEvent(LoggingEvent event) {
- return event.level.isGreaterOrEqual(Level.ERROR);
+ return event.getLevel().isGreaterOrEqual(Level.ERROR);
}
}
diff --git a/src/main/java/org/apache/log4j/net/SimpleSocketServer.java b/src/main/java/org/apache/log4j/net/SimpleSocketServer.java
new file mode 100644
index 0000000000..d591bd01d1
--- /dev/null
+++ b/src/main/java/org/apache/log4j/net/SimpleSocketServer.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.net;
+
+import java.net.Socket;
+import java.net.ServerSocket;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.xml.DOMConfigurator;
+
+
+/**
+ * A simple {@link SocketNode} based server.
+ *
+
+ Usage: java org.apache.log4j.net.SimpleSocketServer port configFile
+
+ where port is a part number where the server listens and
+ configFile is a configuration file fed to the {@link
+ PropertyConfigurator} or to {@link DOMConfigurator} if an XML file.
+
+ *
+ * @author Ceki Gülcü
+ *
+ * @since 0.8.4
+ * */
+public class SimpleSocketServer {
+
+ static Logger cat = Logger.getLogger(SimpleSocketServer.class);
+
+ static int port;
+
+ public
+ static
+ void main(String argv[]) {
+ if(argv.length == 2) {
+ init(argv[0], argv[1]);
+ } else {
+ usage("Wrong number of arguments.");
+ }
+
+ try {
+ cat.info("Listening on port " + port);
+ ServerSocket serverSocket = new ServerSocket(port);
+ while(true) {
+ cat.info("Waiting to accept a new client.");
+ Socket socket = serverSocket.accept();
+ cat.info("Connected to client at " + socket.getInetAddress());
+ cat.info("Starting new socket node.");
+ new Thread(new SocketNode(socket,
+ LogManager.getLoggerRepository())).start();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ static void usage(String msg) {
+ System.err.println(msg);
+ System.err.println(
+ "Usage: java " +SimpleSocketServer.class.getName() + " port configFile");
+ System.exit(1);
+ }
+
+ static void init(String portStr, String configFile) {
+ try {
+ port = Integer.parseInt(portStr);
+ } catch(java.lang.NumberFormatException e) {
+ e.printStackTrace();
+ usage("Could not interpret port number ["+ portStr +"].");
+ }
+
+ if(configFile.endsWith(".xml")) {
+ DOMConfigurator.configure(configFile);
+ } else {
+ PropertyConfigurator.configure(configFile);
+ }
+ }
+}
diff --git a/src/java/org/apache/log4j/net/SocketAppender.java b/src/main/java/org/apache/log4j/net/SocketAppender.java
similarity index 76%
rename from src/java/org/apache/log4j/net/SocketAppender.java
rename to src/main/java/org/apache/log4j/net/SocketAppender.java
index 6b91beaa25..0a9bdb2894 100644
--- a/src/java/org/apache/log4j/net/SocketAppender.java
+++ b/src/main/java/org/apache/log4j/net/SocketAppender.java
@@ -1,24 +1,33 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
// Contributors: Dan MacDonald address and port.
*/
- public
- SocketAppender(InetAddress address, int port) {
+ public SocketAppender(InetAddress address, int port) {
this.address = address;
this.remoteHost = address.getHostName();
this.port = port;
@@ -139,8 +148,7 @@ public SocketAppender() {
/**
Connects to remote server at host and port.
*/
- public
- SocketAppender(String host, int port) {
+ public SocketAppender(String host, int port) {
this.port = port;
this.address = getAddressByName(host);
this.remoteHost = host;
@@ -150,19 +158,17 @@ public SocketAppender() {
/**
Connect to the specified RemoteHost and Port.
*/
- public
- void activateOptions() {
+ public void activateOptions() {
connect(address, port);
}
/**
- Close this appender.
- false.
- */
- public
- boolean requiresLayout() {
+ * The SocketAppender does not use a layout. Hence, this method
+ * returns false.
+ * */
+ public boolean requiresLayout() {
return false;
}
/**
- The RemoteHost option takes a string value which should be
- the host name of the server where a {@link SocketNode} is running.
- */
- public
- void setRemoteHost(String host) {
+ * The RemoteHost option takes a string value which should be
+ * the host name of the server where a {@link SocketNode} is
+ * running.
+ * */
+ public void setRemoteHost(String host) {
address = getAddressByName(host);
remoteHost = host;
}
@@ -288,8 +298,7 @@ void setRemoteHost(String host) {
/**
Returns value of the RemoteHost option.
*/
- public
- String getRemoteHost() {
+ public String getRemoteHost() {
return remoteHost;
}
@@ -297,16 +306,14 @@ String getRemoteHost() {
The Port option takes a positive integer representing
the port where the server is waiting for connections.
*/
- public
- void setPort(int port) {
+ public void setPort(int port) {
this.port = port;
}
/**
Returns value of the Port option.
*/
- public
- int getPort() {
+ public int getPort() {
return port;
}
@@ -315,16 +322,14 @@ int getPort() {
the information sent to the remote host will include location
information. By default no location information is sent to the server.
*/
- public
- void setLocationInfo(boolean locationInfo) {
+ public void setLocationInfo(boolean locationInfo) {
this.locationInfo = locationInfo;
}
/**
Returns value of the LocationInfo option.
*/
- public
- boolean getLocationInfo() {
+ public boolean getLocationInfo() {
return locationInfo;
}
@@ -337,16 +342,14 @@ boolean getLocationInfo() {
toString method.
+
+ @author Ceki Gülcü
+ @since 1.0 */
+class DefaultRenderer implements ObjectRenderer {
+
+ DefaultRenderer() {
+ }
+
+ /**
+ Render the object passed as parameter by calling its
+ toString method. */
+ public
+ String doRender(Object o) {
+ return o.toString();
+ }
+}
diff --git a/src/main/java/org/apache/log4j/or/ObjectRenderer.java b/src/main/java/org/apache/log4j/or/ObjectRenderer.java
new file mode 100644
index 0000000000..8ad99439e8
--- /dev/null
+++ b/src/main/java/org/apache/log4j/or/ObjectRenderer.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.or;
+
+/**
+ Implement this interface in order to render objects as strings.
+
+ @author Ceki Gülcü
+ @since 1.0 */
+public interface ObjectRenderer {
+
+ /**
+ Render the object passed as parameter as a String.
+ */
+ public
+ String doRender(Object o);
+}
diff --git a/src/java/org/apache/log4j/or/RendererMap.java b/src/main/java/org/apache/log4j/or/RendererMap.java
similarity index 84%
rename from src/java/org/apache/log4j/or/RendererMap.java
rename to src/main/java/org/apache/log4j/or/RendererMap.java
index 79094786a4..f60bd5a967 100644
--- a/src/java/org/apache/log4j/or/RendererMap.java
+++ b/src/main/java/org/apache/log4j/or/RendererMap.java
@@ -1,14 +1,25 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.or;
import org.apache.log4j.spi.RendererSupport;
import org.apache.log4j.helpers.LogLog;
+import org.apache.log4j.helpers.Loader;
import org.apache.log4j.helpers.OptionConverter;
import java.util.Hashtable;
@@ -46,7 +57,7 @@ void addRenderer(RendererSupport repository, String renderedClassName,
return;
} else {
try {
- Class renderedClass = Class.forName(renderedClassName);
+ Class renderedClass = Loader.loadClass(renderedClassName);
repository.setRenderer(renderedClass, renderer);
} catch(ClassNotFoundException e) {
LogLog.error("Could not find class ["+renderedClassName+"].", e);
diff --git a/src/java/org/apache/log4j/or/ThreadGroupRenderer.java b/src/main/java/org/apache/log4j/or/ThreadGroupRenderer.java
similarity index 66%
rename from src/java/org/apache/log4j/or/ThreadGroupRenderer.java
rename to src/main/java/org/apache/log4j/or/ThreadGroupRenderer.java
index db00814b4e..8dd70ccc59 100644
--- a/src/java/org/apache/log4j/or/ThreadGroupRenderer.java
+++ b/src/main/java/org/apache/log4j/or/ThreadGroupRenderer.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.APL file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.or;
diff --git a/src/java/org/apache/log4j/or/jms/MessageRenderer.java b/src/main/java/org/apache/log4j/or/jms/MessageRenderer.java
similarity index 69%
rename from src/java/org/apache/log4j/or/jms/MessageRenderer.java
rename to src/main/java/org/apache/log4j/or/jms/MessageRenderer.java
index b1da5f8518..e3140cbba5 100644
--- a/src/java/org/apache/log4j/or/jms/MessageRenderer.java
+++ b/src/main/java/org/apache/log4j/or/jms/MessageRenderer.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.or.jms;
diff --git a/src/java/org/apache/log4j/or/jms/package.html b/src/main/java/org/apache/log4j/or/jms/package.html
similarity index 100%
rename from src/java/org/apache/log4j/or/jms/package.html
rename to src/main/java/org/apache/log4j/or/jms/package.html
diff --git a/src/java/org/apache/log4j/or/package.html b/src/main/java/org/apache/log4j/or/package.html
similarity index 100%
rename from src/java/org/apache/log4j/or/package.html
rename to src/main/java/org/apache/log4j/or/package.html
diff --git a/src/java/org/apache/log4j/or/sax/AttributesRenderer.java b/src/main/java/org/apache/log4j/or/sax/AttributesRenderer.java
similarity index 51%
rename from src/java/org/apache/log4j/or/sax/AttributesRenderer.java
rename to src/main/java/org/apache/log4j/or/sax/AttributesRenderer.java
index 73f006f8f7..136fa97abb 100644
--- a/src/java/org/apache/log4j/or/sax/AttributesRenderer.java
+++ b/src/main/java/org/apache/log4j/or/sax/AttributesRenderer.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.or.sax;
diff --git a/src/java/org/apache/log4j/or/sax/package.html b/src/main/java/org/apache/log4j/or/sax/package.html
similarity index 100%
rename from src/java/org/apache/log4j/or/sax/package.html
rename to src/main/java/org/apache/log4j/or/sax/package.html
diff --git a/src/java/org/apache/log4j/package.html b/src/main/java/org/apache/log4j/package.html
similarity index 100%
rename from src/java/org/apache/log4j/package.html
rename to src/main/java/org/apache/log4j/package.html
diff --git a/src/java/org/apache/log4j/spi/AppenderAttachable.java b/src/main/java/org/apache/log4j/spi/AppenderAttachable.java
similarity index 57%
rename from src/java/org/apache/log4j/spi/AppenderAttachable.java
rename to src/main/java/org/apache/log4j/spi/AppenderAttachable.java
index 3b4cde3f11..89d7ef4209 100644
--- a/src/java/org/apache/log4j/spi/AppenderAttachable.java
+++ b/src/main/java/org/apache/log4j/spi/AppenderAttachable.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.spi;
diff --git a/src/main/java/org/apache/log4j/spi/Configurator.java b/src/main/java/org/apache/log4j/spi/Configurator.java
new file mode 100644
index 0000000000..32ff72dcea
--- /dev/null
+++ b/src/main/java/org/apache/log4j/spi/Configurator.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.spi;
+
+import org.apache.log4j.spi.LoggerRepository;
+import java.net.URL;
+
+/**
+ Implemented by classes capable of configuring log4j using a URL.
+
+ @since 1.0
+ @author Anders Kristensen
+ */
+public interface Configurator {
+
+ /**
+ Special level value signifying inherited behaviour. The current
+ value of this string constant is inherited. {@link #NULL}
+ is a synonym. */
+ public static final String INHERITED = "inherited";
+
+ /**
+ Special level signifying inherited behaviour, same as {@link
+ #INHERITED}. The current value of this string constant is
+ null. */
+ public static final String NULL = "null";
+
+
+
+ /**
+ Interpret a resource pointed by a URL and set up log4j accordingly.
+
+ The configuration is done relative to the hierarchy
+ parameter.
+
+ @param url The URL to parse
+ @param repository The hierarchy to operation upon.
+ */
+ void doConfigure(URL url, LoggerRepository repository);
+}
diff --git a/src/main/java/org/apache/log4j/spi/DefaultRepositorySelector.java b/src/main/java/org/apache/log4j/spi/DefaultRepositorySelector.java
new file mode 100644
index 0000000000..4b307524e4
--- /dev/null
+++ b/src/main/java/org/apache/log4j/spi/DefaultRepositorySelector.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+package org.apache.log4j.spi;
+
+
+public class DefaultRepositorySelector implements RepositorySelector {
+
+ final LoggerRepository repository;
+
+ public
+ DefaultRepositorySelector(LoggerRepository repository) {
+ this.repository = repository;
+ }
+
+ public
+ LoggerRepository getLoggerRepository() {
+ return repository;
+ }
+}
+
diff --git a/src/main/java/org/apache/log4j/spi/ErrorCode.java b/src/main/java/org/apache/log4j/spi/ErrorCode.java
new file mode 100644
index 0000000000..b0e57f1fe7
--- /dev/null
+++ b/src/main/java/org/apache/log4j/spi/ErrorCode.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.spi;
+
+
+/**
+ This interface defines commonly encoutered error codes.
+
+ @author Ceki Gülcü
+ @since 0.9.0
+ */
+public interface ErrorCode {
+
+ public final int GENERIC_FAILURE = 0;
+ public final int WRITE_FAILURE = 1;
+ public final int FLUSH_FAILURE = 2;
+ public final int CLOSE_FAILURE = 3;
+ public final int FILE_OPEN_FAILURE = 4;
+ public final int MISSING_LAYOUT = 5;
+ public final int ADDRESS_PARSE_FAILURE = 6;
+}
diff --git a/src/java/org/apache/log4j/spi/ErrorHandler.java b/src/main/java/org/apache/log4j/spi/ErrorHandler.java
similarity index 72%
rename from src/java/org/apache/log4j/spi/ErrorHandler.java
rename to src/main/java/org/apache/log4j/spi/ErrorHandler.java
index 9eb70a2884..d629a2dbd2 100644
--- a/src/java/org/apache/log4j/spi/ErrorHandler.java
+++ b/src/main/java/org/apache/log4j/spi/ErrorHandler.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.spi;
diff --git a/src/java/org/apache/log4j/spi/Filter.java b/src/main/java/org/apache/log4j/spi/Filter.java
similarity index 72%
rename from src/java/org/apache/log4j/spi/Filter.java
rename to src/main/java/org/apache/log4j/spi/Filter.java
index 3f12dbd699..b54d875ce9 100644
--- a/src/java/org/apache/log4j/spi/Filter.java
+++ b/src/main/java/org/apache/log4j/spi/Filter.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.spi;
@@ -53,6 +63,8 @@ public abstract class Filter implements OptionHandler {
/**
Points to the next filter in the filter chain.
+
+ @deprecated As of 1.2.12, use {@link #getNext} and {@link #setNext} instead
*/
public Filter next;
@@ -91,9 +103,23 @@ void activateOptions() {
the chain.
@param event The LoggingEvent to decide upon.
- @param decision The decision of the filter. */
+ @return decision The decision of the filter. */
abstract
public
int decide(LoggingEvent event);
+ /**
+ * Set the next filter pointer.
+ */
+ public void setNext(Filter next) {
+ this.next = next;
+ }
+
+ /**
+ * Return the pointer to the next filter;
+ */
+ public Filter getNext() {
+ return next;
+ }
+
}
diff --git a/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java b/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java
new file mode 100644
index 0000000000..9215926913
--- /dev/null
+++ b/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.spi;
+
+import org.apache.log4j.*;
+
+/**
+ Listen to events occuring within a {@link
+ org.apache.log4j.Hierarchy Hierarchy}.
+
+ @author Ceki Gülcü
+ @since 1.2
+
+ */
+public interface HierarchyEventListener {
+
+
+ //public
+ //void categoryCreationEvent(Category cat);
+
+
+ public
+ void addAppenderEvent(Category cat, Appender appender);
+
+ public
+ void removeAppenderEvent(Category cat, Appender appender);
+
+
+}
diff --git a/src/java/org/apache/log4j/spi/LocationInfo.java b/src/main/java/org/apache/log4j/spi/LocationInfo.java
similarity index 70%
rename from src/java/org/apache/log4j/spi/LocationInfo.java
rename to src/main/java/org/apache/log4j/spi/LocationInfo.java
index eb0d505aa4..80df1d02fe 100644
--- a/src/java/org/apache/log4j/spi/LocationInfo.java
+++ b/src/main/java/org/apache/log4j/spi/LocationInfo.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// Contributors: Mathias Rupprecht examples/subclass/MyLogger.java for an example.
+
+ @author Ceki Gülcü
+ @since version 0.8.5
+
+ */
+public interface LoggerFactory {
+
+ public
+ Logger makeNewLoggerInstance(String name);
+
+}
diff --git a/src/java/org/apache/log4j/spi/LoggerRepository.java b/src/main/java/org/apache/log4j/spi/LoggerRepository.java
similarity index 63%
rename from src/java/org/apache/log4j/spi/LoggerRepository.java
rename to src/main/java/org/apache/log4j/spi/LoggerRepository.java
index 22ce2b32fc..46701a61c8 100644
--- a/src/java/org/apache/log4j/spi/LoggerRepository.java
+++ b/src/main/java/org/apache/log4j/spi/LoggerRepository.java
@@ -1,9 +1,19 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.spi;
@@ -31,9 +41,10 @@ public interface LoggerRepository {
void addHierarchyEventListener(HierarchyEventListener listener);
/**
- Is the repository disabled for a given level? The answer depends
- on the repository threshold and the level
- parameter. See also {@link #setThreshold} method. */
+ Returns whether this repository is disabled for a given
+ level. The answer depends on the repository threshold and the
+ level parameter. See also {@link #setThreshold}
+ method. */
boolean isDisabled(int level);
/**
@@ -79,7 +90,7 @@ public interface LoggerRepository {
Enumeration getCurrentLoggers();
/**
- @deprecated Please use {@link #getCurrentLoggers} instead. */
+ Deprecated. Please use {@link #getCurrentLoggers} instead. */
public
Enumeration getCurrentCategories();
diff --git a/src/java/org/apache/log4j/spi/LoggingEvent.java b/src/main/java/org/apache/log4j/spi/LoggingEvent.java
similarity index 51%
rename from src/java/org/apache/log4j/spi/LoggingEvent.java
rename to src/main/java/org/apache/log4j/spi/LoggingEvent.java
index 5cd6e42dc7..57c8a53c82 100644
--- a/src/java/org/apache/log4j/spi/LoggingEvent.java
+++ b/src/main/java/org/apache/log4j/spi/LoggingEvent.java
@@ -1,20 +1,34 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software
- * License version 1.1, a copy of which has been included with this
- * distribution in the LICENSE.txt file. */
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.log4j.spi;
import org.apache.log4j.*;
import org.apache.log4j.helpers.LogLog;
-
+import org.apache.log4j.helpers.Loader;
import java.lang.reflect.Method;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.util.Hashtable;
+import java.util.Set;
+import java.util.Collections;
+import java.util.Map;
+import java.util.HashMap;
// Contributors: Nelson Minar LoggingEvent are filled when actually needed.
LoggingEvent are filled when actually needed.
level field. */
+ public Level getLevel() {
+ return (Level) level;
+ }
+
+ /**
+ * Return the name of the logger. Use this form instead of directly
+ * accessing the categoryName field.
+ */
+ public String getLoggerName() {
+ return categoryName;
+ }
+
+ /**
+ * Gets the logger of the event.
+ * Use should be restricted to cloning events.
+ * @since 1.2.15
+ */
+ public Category getLogger() {
+ return logger;
+ }
/**
Return the message for this logging event.
@@ -187,6 +291,11 @@ Object getMessage() {
}
}
+ /**
+ * This method returns the NDC for this event. It will return the
+ * correct content even if the event was generated in a different
+ * thread or even on a different machine. The {@link NDC#get} method
+ * should never be called directly. */
public
String getNDC() {
if(ndcLookupRequired) {
@@ -199,9 +308,11 @@ String getNDC() {
/**
Returns the the context corresponding to the key
- parameter. If there is a local MDC copy (probably from a remote
- machine, the we use it, if that fails then the current thread's
- MDC is used.
+ parameter. If there is a local MDC copy, possibly because we are
+ in a logging server or running inside AsyncAppender, then we
+ search for the key in MDC copy, if a value is found it is
+ returned. Otherwise, if the search in MDC copy returns a null
+ result, then the current thread's MDC is used.
null
- priority. Second, since root category cannot have a parent, the
- {@link #getChainedLevel} method always returns the value of the
- level field without walking the hierarchy.
-
- @author Ceki Gülcü
-
+ * @deprecated Replaced by {@link RootLogger}.
*/
final public class RootCategory extends Logger {
diff --git a/src/main/java/org/apache/log4j/spi/RootLogger.java b/src/main/java/org/apache/log4j/spi/RootLogger.java
new file mode 100644
index 0000000000..02f7cd31e8
--- /dev/null
+++ b/src/main/java/org/apache/log4j/spi/RootLogger.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.spi;
+
+import org.apache.log4j.*;
+import org.apache.log4j.helpers.LogLog;
+
+
+// Contibutors: Mathias Bogaert
+
+/**
+ RootLogger sits at the top of the logger hierachy. It is a
+ regular logger except that it provides several guarantees.
+
+ null
+ level. Second, since root logger cannot have a parent, the
+ {@link #getChainedLevel} method always returns the value of the
+ level field without walking the hierarchy.
+
+ @author Ceki Gülcü
+
+ */
+public final class RootLogger extends Logger {
+ /**
+ The root logger names itself as "root". However, the root
+ logger cannot be retrieved by name.
+ */
+ public RootLogger(Level level) {
+ super("root");
+ setLevel(level);
+ }
+
+ /**
+ Return the assigned level value without walking the logger
+ hierarchy.
+ */
+ public final Level getChainedLevel() {
+ return level;
+ }
+
+ /**
+ Setting a null value to the level of the root logger may have catastrophic
+ results. We prevent this here.
+
+ @since 0.8.3 */
+ public final void setLevel(Level level) {
+ if (level == null) {
+ LogLog.error(
+ "You have tried to set a null level to root.", new Throwable());
+ } else {
+ this.level = level;
+ }
+ }
+
+}
diff --git a/src/main/java/org/apache/log4j/spi/ThrowableInformation.java b/src/main/java/org/apache/log4j/spi/ThrowableInformation.java
new file mode 100644
index 0000000000..b98d0f5d1f
--- /dev/null
+++ b/src/main/java/org/apache/log4j/spi/ThrowableInformation.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.spi;
+
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+
+/**
+ * ThrowableInformation is log4j's internal representation of
+ * throwables. It essentially consists of a string array, called
+ * 'rep', where the first element, that is rep[0], represents the
+ * string representation of the throwable (i.e. the value you get
+ * when you do throwable.toString()) and subsequent elements
+ * correspond the stack trace with the top most entry of the stack
+ * corresponding to the second entry of the 'rep' array that is
+ * rep[1].
+ *
+ * @author Ceki Gülcü
+ *
+ * */
+public class ThrowableInformation implements java.io.Serializable {
+
+ static final long serialVersionUID = -4748765566864322735L;
+
+ private transient Throwable throwable;
+ private String[] rep;
+
+ public
+ ThrowableInformation(Throwable throwable) {
+ this.throwable = throwable;
+ }
+
+ /**
+ * Create new instance.
+ * @since 1.2.15
+ * @param r String representation of throwable.
+ */
+ public ThrowableInformation(final String[] r) {
+ if (r != null) {
+ rep = (String[]) r.clone();
+ }
+ }
+
+
+ public
+ Throwable getThrowable() {
+ return throwable;
+ }
+
+ public
+ String[] getThrowableStrRep() {
+ if(rep != null) {
+ return (String[]) rep.clone();
+ } else {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ throwable.printStackTrace(pw);
+ pw.flush();
+ LineNumberReader reader = new LineNumberReader(
+ new StringReader(sw.toString()));
+ ArrayList lines = new ArrayList();
+ try {
+ String line = reader.readLine();
+ while(line != null) {
+ lines.add(line);
+ line = reader.readLine();
+ }
+ } catch(IOException ex) {
+ lines.add(ex.toString());
+ }
+ rep = new String[lines.size()];
+ lines.toArray(rep);
+ }
+ return rep;
+ }
+}
+
+
diff --git a/src/main/java/org/apache/log4j/spi/TriggeringEventEvaluator.java b/src/main/java/org/apache/log4j/spi/TriggeringEventEvaluator.java
new file mode 100644
index 0000000000..67f4fcd01d
--- /dev/null
+++ b/src/main/java/org/apache/log4j/spi/TriggeringEventEvaluator.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.spi;
+
+/**
+
+ Implementions of this interface allow certain appenders to decide
+ when to perform an appender specific action.
+
+ true and adds the event to an internal buffer when the
+ returned result is false.
+
+ @author Ceki Gülcü
+ @since version 1.0
+
+ */
+public interface TriggeringEventEvaluator {
+
+ /**
+ Is this the triggering event?
+ */
+ public boolean isTriggeringEvent(LoggingEvent event);
+}
diff --git a/src/main/java/org/apache/log4j/spi/VectorWriter.java b/src/main/java/org/apache/log4j/spi/VectorWriter.java
new file mode 100644
index 0000000000..3e288605ac
--- /dev/null
+++ b/src/main/java/org/apache/log4j/spi/VectorWriter.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.spi;
+
+import java.io.PrintWriter;
+import java.util.Vector;
+
+/**
+ * VectorWriter is an obsolete class provided only for
+ * binary compatibility with earlier versions of log4j and should not be used.
+ *
+ * @deprecated
+ */
+class VectorWriter extends PrintWriter {
+
+ private Vector v;
+
+ /**
+ * @deprecated
+ */
+ VectorWriter() {
+ super(new NullWriter());
+ v = new Vector();
+ }
+
+ public void print(Object o) {
+ v.addElement(String.valueOf(o));
+ }
+
+ public void print(char[] chars) {
+ v.addElement(new String(chars));
+ }
+
+ public void print(String s) {
+ v.addElement(s);
+ }
+
+ public void println(Object o) {
+ v.addElement(String.valueOf(o));
+ }
+
+ // JDK 1.1.x apprenly uses this form of println while in
+ // printStackTrace()
+ public
+ void println(char[] chars) {
+ v.addElement(new String(chars));
+ }
+
+ public
+ void println(String s) {
+ v.addElement(s);
+ }
+
+ public void write(char[] chars) {
+ v.addElement(new String(chars));
+ }
+
+ public void write(char[] chars, int off, int len) {
+ v.addElement(new String(chars, off, len));
+ }
+
+ public void write(String s, int off, int len) {
+ v.addElement(s.substring(off, off+len));
+ }
+
+ public void write(String s) {
+ v.addElement(s);
+ }
+
+ public String[] toStringArray() {
+ int len = v.size();
+ String[] sa = new String[len];
+ for(int i = 0; i < len; i++) {
+ sa[i] = (String) v.elementAt(i);
+ }
+ return sa;
+ }
+
+}
+
diff --git a/src/java/org/apache/log4j/spi/package.html b/src/main/java/org/apache/log4j/spi/package.html
similarity index 100%
rename from src/java/org/apache/log4j/spi/package.html
rename to src/main/java/org/apache/log4j/spi/package.html
diff --git a/src/java/org/apache/log4j/varia/DenyAllFilter.java b/src/main/java/org/apache/log4j/varia/DenyAllFilter.java
similarity index 61%
rename from src/java/org/apache/log4j/varia/DenyAllFilter.java
rename to src/main/java/org/apache/log4j/varia/DenyAllFilter.java
index 9e59f4b33a..6c9e949396 100644
--- a/src/java/org/apache/log4j/varia/DenyAllFilter.java
+++ b/src/main/java/org/apache/log4j/varia/DenyAllFilter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.varia;
diff --git a/src/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java b/src/main/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java
similarity index 80%
rename from src/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java
rename to src/main/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java
index 736abe1baf..7e284b7e83 100644
--- a/src/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java
+++ b/src/main/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java
@@ -1,20 +1,30 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.APL file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.varia;
-import java.io.*;
-import java.net.Socket;
-import java.net.ServerSocket;
-import org.apache.log4j.helpers.LogLog;
import org.apache.log4j.RollingFileAppender;
import org.apache.log4j.helpers.LogLog;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+
/**
This appender listens on a socket on the port specified by the
Port property for a "RollOver" message. When such a message
diff --git a/src/java/org/apache/log4j/varia/FallbackErrorHandler.java b/src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java
similarity index 51%
rename from src/java/org/apache/log4j/varia/FallbackErrorHandler.java
rename to src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java
index a7ebb9f00a..dc51347e38 100644
--- a/src/java/org/apache/log4j/varia/FallbackErrorHandler.java
+++ b/src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.varia;
@@ -16,16 +25,17 @@
import java.util.Vector;
/**
-
- The FallbackErrorHandler implements the ErrorHandler
- interface such that a secondary appender may be specified. This
- secondary appender takes over if the primary appender fails for
- whatever reason.
-
- System.err, and
- logged in the new secondary appender.
-
-*/
+ *
+ * The FallbackErrorHandler implements the ErrorHandler
+ * interface such that a secondary appender may be specified. This
+ * secondary appender takes over if the primary appender fails for
+ * whatever reason.
+ *
+ * System.err, and
+ * logged in the new secondary appender.
+ *
+ * @author Ceki Gücü
+ * */
public class FallbackErrorHandler implements ErrorHandler {
@@ -73,17 +83,20 @@ void error(String message, Exception e, int errorCode) {
*/
public
void error(String message, Exception e, int errorCode, LoggingEvent event) {
- for(int i = 0; i < loggers.size(); i++) {
- Logger l = (Logger) loggers.elementAt(i);
- LogLog.debug("FB: Searching for ["+primary.getName()+"] in logger"
- +l.getName());
- //if(l.isAttached(primary)) {
- LogLog.debug("FB: Replacing ["+primary.getName()+"] by ["
- + backup.getName() + " in logger"+ l);
- l.removeAppender(primary);
- LogLog.debug("FB: Adding appender ["+backup.getName()+"] to logger "
- + l.getName());
- l.addAppender(backup);
+ LogLog.debug("FB: The following error reported: " + message, e);
+ LogLog.debug("FB: INITIATING FALLBACK PROCEDURE.");
+ if (loggers != null) {
+ for(int i = 0; i < loggers.size(); i++) {
+ Logger l = (Logger) loggers.elementAt(i);
+ LogLog.debug("FB: Searching for ["+primary.getName()+"] in logger ["
+ +l.getName() + "].");
+ LogLog.debug("FB: Replacing ["+primary.getName()+"] by ["
+ + backup.getName() + "] in logger ["+ l.getName() +"].");
+ l.removeAppender(primary);
+ LogLog.debug("FB: Adding appender ["+backup.getName()+"] to logger "
+ + l.getName());
+ l.addAppender(backup);
+ }
}
}
diff --git a/src/java/org/apache/log4j/varia/LevelMatchFilter.java b/src/main/java/org/apache/log4j/varia/LevelMatchFilter.java
similarity index 72%
rename from src/java/org/apache/log4j/varia/LevelMatchFilter.java
rename to src/main/java/org/apache/log4j/varia/LevelMatchFilter.java
index b028c83674..832ca29f2c 100644
--- a/src/java/org/apache/log4j/varia/LevelMatchFilter.java
+++ b/src/main/java/org/apache/log4j/varia/LevelMatchFilter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.APL file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.varia;
@@ -79,7 +88,7 @@ int decide(LoggingEvent event) {
}
boolean matchOccured = false;
- if(this.levelToMatch.equals(event.level)) {
+ if(this.levelToMatch.equals(event.getLevel())) {
matchOccured = true;
}
diff --git a/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java b/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java
new file mode 100644
index 0000000000..9dfacb1be5
--- /dev/null
+++ b/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.varia;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.spi.Filter;
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ This is a very simple filter based on level matching, which can be
+ used to reject messages with priorities outside a certain range.
+
+ LevelMinw is not defined, then there is no
+ minimum acceptable level (ie a level is never rejected for
+ being too "low"/unimportant). If LevelMax is not
+ defined, then there is no maximum acceptable level (ie a
+ level is never rejected for beeing too "high"/important).
+
+ all appenders extending {@link
+ org.apache.log4j.AppenderSkeleton} for a more convenient way to
+ filter out events by level.
+
+ @author Simon Kitching
+ @author based on code by Ceki Gülcü
+*/
+public class LevelRangeFilter extends Filter {
+
+ /**
+ Do we return ACCEPT when a match occurs. Default is
+ false, so that later filters get run by default */
+ boolean acceptOnMatch = false;
+
+ Level levelMin;
+ Level levelMax;
+
+
+ /**
+ Return the decision of this filter.
+ */
+ public
+ int decide(LoggingEvent event) {
+ if(this.levelMin != null) {
+ if (event.getLevel().isGreaterOrEqual(levelMin) == false) {
+ // level of event is less than minimum
+ return Filter.DENY;
+ }
+ }
+
+ if(this.levelMax != null) {
+ if (event.getLevel().toInt() > levelMax.toInt()) {
+ // level of event is greater than maximum
+ // Alas, there is no Level.isGreater method. and using
+ // a combo of isGreaterOrEqual && !Equal seems worse than
+ // checking the int values of the level objects..
+ return Filter.DENY;
+ }
+ }
+
+ if (acceptOnMatch) {
+ // this filter set up to bypass later filters and always return
+ // accept if level in range
+ return Filter.ACCEPT;
+ }
+ else {
+ // event is ok for this filter; allow later filters to have a look..
+ return Filter.NEUTRAL;
+ }
+ }
+
+ /**
+ Get the value of the LevelMax option. */
+ public
+ Level getLevelMax() {
+ return levelMax;
+ }
+
+
+ /**
+ Get the value of the LevelMin option. */
+ public
+ Level getLevelMin() {
+ return levelMin;
+ }
+
+ /**
+ Get the value of the AcceptOnMatch option.
+ */
+ public
+ boolean getAcceptOnMatch() {
+ return acceptOnMatch;
+ }
+
+ /**
+ Set the LevelMax option.
+ */
+ public
+ void setLevelMax(Level levelMax) {
+ this.levelMax = levelMax;
+ }
+
+ /**
+ Set the LevelMin option.
+ */
+ public
+ void setLevelMin(Level levelMin) {
+ this.levelMin = levelMin;
+ }
+
+ /**
+ Set the AcceptOnMatch option.
+ */
+ public
+ void setAcceptOnMatch(boolean acceptOnMatch) {
+ this.acceptOnMatch = acceptOnMatch;
+ }
+}
+
diff --git a/src/main/java/org/apache/log4j/varia/NullAppender.java b/src/main/java/org/apache/log4j/varia/NullAppender.java
new file mode 100644
index 0000000000..5ef78dc3ce
--- /dev/null
+++ b/src/main/java/org/apache/log4j/varia/NullAppender.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.varia;
+
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ * A NullAppender merely exists, it never outputs a message to any
+ * device.
+ * @author Ceki Gülc¨
+ */
+public class NullAppender extends AppenderSkeleton {
+
+ private static NullAppender instance = new NullAppender();
+
+ public NullAppender() {
+ }
+
+ /**
+ * There are no options to acticate.
+ * */
+ public void activateOptions() {
+ }
+
+ /**
+ * Whenever you can, use this method to retreive an instance instead
+ * of instantiating a new one with new.
+ * */
+ public NullAppender getInstance() {
+ return instance;
+ }
+
+ public void close() {
+ }
+
+ /**
+ * Does not do anything.
+ * */
+ public void doAppend(LoggingEvent event) {
+ }
+
+ /**
+ * Does not do anything.
+ * */
+ protected void append(LoggingEvent event) {
+ }
+
+ /**
+ * NullAppenders do not need a layout.
+ * */
+ public boolean requiresLayout() {
+ return false;
+ }
+}
diff --git a/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java b/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java
new file mode 100644
index 0000000000..b29e84761b
--- /dev/null
+++ b/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.varia;
+
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.spi.Configurator;
+import java.net.URL;
+import org.apache.log4j.spi.LoggerRepository;
+
+public class ReloadingPropertyConfigurator implements Configurator {
+
+
+ PropertyConfigurator delegate = new PropertyConfigurator();
+
+
+ public ReloadingPropertyConfigurator() {
+ }
+
+ public
+ void doConfigure(URL url, LoggerRepository repository) {
+ }
+
+}
diff --git a/src/java/org/apache/log4j/varia/Roller.java b/src/main/java/org/apache/log4j/varia/Roller.java
similarity index 71%
rename from src/java/org/apache/log4j/varia/Roller.java
rename to src/main/java/org/apache/log4j/varia/Roller.java
index d416896a40..7ef3aee610 100644
--- a/src/java/org/apache/log4j/varia/Roller.java
+++ b/src/main/java/org/apache/log4j/varia/Roller.java
@@ -1,14 +1,23 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.varia;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;
import java.io.IOException;
@@ -29,7 +38,7 @@
@since version 0.9.0 */
public class Roller {
- static Category cat = Category.getInstance(Roller.class.getName());
+ static Logger cat = Logger.getLogger(Roller.class);
static String host;
diff --git a/src/java/org/apache/log4j/varia/StringMatchFilter.java b/src/main/java/org/apache/log4j/varia/StringMatchFilter.java
similarity index 61%
rename from src/java/org/apache/log4j/varia/StringMatchFilter.java
rename to src/main/java/org/apache/log4j/varia/StringMatchFilter.java
index 457eddf31a..6ee7ec473b 100644
--- a/src/java/org/apache/log4j/varia/StringMatchFilter.java
+++ b/src/main/java/org/apache/log4j/varia/StringMatchFilter.java
@@ -1,9 +1,18 @@
/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE.txt file.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.log4j.varia;
@@ -13,29 +22,19 @@
import org.apache.log4j.helpers.OptionConverter;
/**
- This is a very simple filter based on string matching.
-
-
- StringMatchFilter.
-
-
- @author Ceki Gülcü
-
- @since 0.9.0 */
+ * This is a very simple filter based on string matching.
+ *
+ * filename to reconfigure log4j. */
public
void doOnChange() {
diff --git a/src/main/java/org/apache/log4j/xml/Log4jEntityResolver.java b/src/main/java/org/apache/log4j/xml/Log4jEntityResolver.java
new file mode 100644
index 0000000000..a1b939e1e5
--- /dev/null
+++ b/src/main/java/org/apache/log4j/xml/Log4jEntityResolver.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.xml;
+
+import org.apache.log4j.helpers.LogLog;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+import java.io.InputStream;
+
+/**
+ * An {@link EntityResolver} specifically designed to return
+ * log4j.dtd which is embedded within the log4j jar
+ * file.
+ *
+ * @author Paul Austin
+ * */
+public class Log4jEntityResolver implements EntityResolver {
+
+ public InputSource resolveEntity (String publicId, String systemId) {
+ if (systemId.endsWith("log4j.dtd")) {
+ Class clazz = getClass();
+ InputStream in = clazz.getResourceAsStream("/org/apache/log4j/xml/log4j.dtd");
+ if (in == null) {
+ LogLog.error("Could not find [log4j.dtd]. Used [" + clazz.getClassLoader()
+ + "] class loader in the search.");
+ return null;
+ } else {
+ return new InputSource(in);
+ }
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/org/apache/log4j/xml/SAXErrorHandler.java b/src/main/java/org/apache/log4j/xml/SAXErrorHandler.java
new file mode 100644
index 0000000000..43e851bb6c
--- /dev/null
+++ b/src/main/java/org/apache/log4j/xml/SAXErrorHandler.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.xml;
+
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXParseException;
+import org.apache.log4j.helpers.LogLog;
+
+public class SAXErrorHandler implements ErrorHandler {
+
+ public
+ void error(final SAXParseException ex) {
+ emitMessage("Continuable parsing error ", ex);
+ }
+
+ public
+ void fatalError(final SAXParseException ex) {
+ emitMessage("Fatal parsing error ", ex);
+ }
+
+ public
+ void warning(final SAXParseException ex) {
+ emitMessage("Parsing warning ", ex);
+ }
+
+ private static void emitMessage(final String msg, final SAXParseException ex) {
+ LogLog.warn(msg +ex.getLineNumber()+" and column "
+ +ex.getColumnNumber());
+ LogLog.warn(ex.getMessage(), ex.getException());
+ }
+}
diff --git a/src/main/java/org/apache/log4j/xml/UnrecognizedElementHandler.java b/src/main/java/org/apache/log4j/xml/UnrecognizedElementHandler.java
new file mode 100644
index 0000000000..463d5d989d
--- /dev/null
+++ b/src/main/java/org/apache/log4j/xml/UnrecognizedElementHandler.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.xml;
+
+import org.w3c.dom.Element;
+import java.util.Properties;
+
+/**
+ * When implemented by an object configured by DOMConfigurator,
+ * the handle method will be called when an unrecognized child
+ * element is encountered. Unrecognized child elements of
+ * the log4j:configuration element will be dispatched to
+ * the logger repository if it supports this interface.
+ *
+ * @since 1.2.15
+ */
+public interface UnrecognizedElementHandler {
+ /**
+ * Called to inform a configured object when
+ * an unrecognized child element is encountered.
+ * @param element element, may not be null.
+ * @param props properties in force, may be null.
+ * @return true if configured object recognized the element
+ * @throws Exception throw an exception to prevent activation
+ * of the configured object.
+ */
+ boolean parseUnrecognizedElement(Element element, Properties props) throws Exception;
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/log4j/xml/XMLLayout.java b/src/main/java/org/apache/log4j/xml/XMLLayout.java
new file mode 100644
index 0000000000..62cc5d8f29
--- /dev/null
+++ b/src/main/java/org/apache/log4j/xml/XMLLayout.java
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Contributors: Mathias Bogaert
+
+package org.apache.log4j.xml;
+
+import org.apache.log4j.Layout;
+import org.apache.log4j.helpers.Transform;
+import org.apache.log4j.spi.LocationInfo;
+import org.apache.log4j.spi.LoggingEvent;
+
+import java.util.Set;
+import java.util.Arrays;
+
+/**
+ * The output of the XMLLayout consists of a series of log4j:event
+ * elements as defined in the log4j.dtd. It does not output a
+ * complete well-formed XML file. The output is designed to be
+ * included as an external entity in a separate file to form
+ * a correct XML file.
+ *
+ * abc is the name of the file where
+ * the XMLLayout ouput goes, then a well-formed XML file would be:
+ *
+
+ <?xml version="1.0" ?>
+
+ <!DOCTYPE log4j:eventSet SYSTEM "log4j.dtd" [<!ENTITY data SYSTEM "abc">]>
+
+ <log4j:eventSet version="1.2" xmlns:log4j="http://jakarta.apache.org/log4j/">
+ &data;
+ </log4j:eventSet>
+
+
+ * version attribute helps components to correctly
+ * intrepret output generated by XMLLayout. The value of this
+ * attribute should be "1.1" for output generated by log4j versions
+ * prior to log4j 1.2 (final release) and "1.2" for relase 1.2 and
+ * later.
+ *
+ * Appenders using this layout should have their encoding
+ * set to UTF-8 or UTF-16, otherwise events containing
+ * non ASCII characters could result in corrupted
+ * log files.
+ *
+ * @author Ceki Gülcü
+ * @since 0.9.0
+ * */
+public class XMLLayout extends Layout {
+
+ private final int DEFAULT_SIZE = 256;
+ private final int UPPER_LIMIT = 2048;
+
+ private StringBuffer buf = new StringBuffer(DEFAULT_SIZE);
+ private boolean locationInfo = false;
+ private boolean properties = false;
+
+ /**
+ * The LocationInfo option takes a boolean value. By default,
+ * it is set to false which means there will be no location
+ * information output by this layout. If the the option is set to
+ * true, then the file name and line number of the statement at the
+ * origin of the log statement will be output.
+ *
+ * false.
+ */
+ public boolean ignoresThrowable() {
+ return false;
+ }
+}
diff --git a/src/java/org/apache/log4j/xml/package.html b/src/main/java/org/apache/log4j/xml/package.html
similarity index 100%
rename from src/java/org/apache/log4j/xml/package.html
rename to src/main/java/org/apache/log4j/xml/package.html
diff --git a/src/main/javadoc/org/apache/log4j/xml/examples/XMLSample.java b/src/main/javadoc/org/apache/log4j/xml/examples/XMLSample.java
new file mode 100644
index 0000000000..8ea09f2844
--- /dev/null
+++ b/src/main/javadoc/org/apache/log4j/xml/examples/XMLSample.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.xml.examples;
+
+import org.apache.log4j.xml.DOMConfigurator;
+import org.apache.log4j.Logger;
+
+/**
+
+ This example code shows how to
+ read an XML based configuration file using a DOM parser.
+
+ org.apache.log4j.performance.NOPWriter class is
+ * intended for internal use only. Consequently, it is not
+ * included in the log4j.jar file. " + t);
t = (int)setLen(len, second);
diff --git a/src/performance/java/org/apache/log4j/performance/NullAppender.java b/src/performance/java/org/apache/log4j/performance/NullAppender.java
new file mode 100644
index 0000000000..32c057ad3b
--- /dev/null
+++ b/src/performance/java/org/apache/log4j/performance/NullAppender.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.performance;
+
+import org.apache.log4j.Layout;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.AppenderSkeleton;
+
+/**
+ * A bogus appender which calls the format method of its layout object
+ * but does not write the result anywhere.
+ *
+ * org.apache.log4j.performance.NullAppender class is
+ * intended for internal use only. Consequently, it is not
+ * included in the log4j.jar file. org.apache.log4j.performance package is intended
+ for internal use only. Consequently, the classes in this
+ package are not included in the log4j.jar file.
+ org.apache.log4j.net.SMTPAppender
+ relies on the JavaMail
+ API. It has been tested with JavaMail API version
+ 1.2. The JavaMail API requires the JavaBeans
+ Activation Framework package.
+ org.apache.log4j.net.JMSAppender
+ requires the presence of the JMS API as well as JNDI.
+ java.io.OutputStream,
+ java.io.Writer, a remote server using TCP, a
+ remote Unix Syslog daemon, to a remote listener using JMS,
+ to the NT EventLog or even send e-mail. Layout
+ class. Appender interface. examples/ directory.
+176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse order.
+225 [main] INFO examples.SortAlgo - Entered the sort method.
+262 [main] DEBUG SortAlgo.OUTER i=1 - Outer loop.
+276 [main] DEBUG SortAlgo.SWAP i=1 j=0 - Swapping intArray[0] = 1 and intArray[1] = 0
+290 [main] DEBUG SortAlgo.OUTER i=0 - Outer loop.
+304 [main] INFO SortAlgo.DUMP - Dump of interger array:
+317 [main] INFO SortAlgo.DUMP - Element [0] = 0
+331 [main] INFO SortAlgo.DUMP - Element [1] = 1
+343 [main] INFO examples.Sort - The next log statement should be an error message.
+346 [main] ERROR SortAlgo.DUMP - Tried to dump an uninitialized array.
+ at org.log4j.examples.SortAlgo.dump(SortAlgo.java:58)
+ at org.log4j.examples.Sort.main(Sort.java:64)
+467 [main] INFO examples.Sort - Exiting main method.
+
+
+ PropertyConfigurator defines a particular format
+ of a configuration file. See also the examples/Sort.java
+ example and associated configuration files.
+ log4j.dtd and
+ org.log4j.xml.DOMConfigurator for more details.
+ l, writing,
+
+ l.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
+
+
+ i and entry[i] to a
+ String, and concatenating intermediate strings. This, regardless of
+ whether the message will be logged or not.
+
+ if(l.isDebugEnabled()) {
+ l.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
+ }
+
+
+ l. On the other hand, if the logger is debug
+ enabled, you will incur the cost of evaluating whether the
+ logger is enabled or not, twice: once in
+ debugEnabled and once in debug.
+ This is an insignificant overhead since evaluating a logger
+ takes less than 1% of the time it takes to actually log a
+ statement.
+
+
+
+ X.class.getName(). Note that X is the class
+ name and not an instance. The X.class statement does
+ not create a new instance of class X.
+
+package a.b.c;
+
+public class Foo {
+ final static Logger logger = Logger.getLogger(Foo.class);
+ ... other code
+
+}
+
+ Layout class to create
+ you own customized log format. Appenders can be parameterized
+ to use the layout of your choice.
+ FooBarAppender?FooBarAppender
+ corresponds to a configurable option. For example, in RollingFileAppender
+ the setMaxBackupIndex(int
+ maxBackups) method corresponds to the
+ maxBackupIndex option. The first letter of the
+ option can be upper case, i.e. MaxBackupIndex
+ and maxBackupIndex are equivalent but not
+ MAXBACKUPIndex nor mAXBackupIndex.
+ NTEventLogAppender?<% ... %> statements
+ as indicated in the Short Manual and the rest of the documentation.
+ NDC and the PatternLayout
+ classes for more information. The NumberCruncher
+ example shows how the NDC can be used to distinguish the log
+ output from multiple clients even if they share the same log
+ file.
+ SocketAppender.
+ The receiving
+ SocketServer
+ (or
+ SimpleSocketServer)
+ can receive all the events and send them to a single
+ log file.
+ debug,
+ info, warn, error or
+ fatal method is invoked. Thus, the timestamp is
+ unaffected by the time at which event arrive at a remote
+ socket server.
+ Class.forName()
+ mechanism for loading classes. Resources are handled
+ similarly. See the documentation for
+ java.lang.ClassLoader for more details.
+ configureAndWatch method.
+ See the API documentation for more details.
+ configureAndWatch launches a
+ separate wathdog thread, and because there is no way to stop
+ this thread in log4j 1.2, the configureAndWatch
+ method is unsafe for use in J2EE envrironments where
+ applications are recycled.
+ n, then when log4j
+ release version n+1 comes out, you will probably
+ need to adapt your proprietary extensions to the new release.
+
+
+
+
+
+ Short introduction to log4j
-
- Ceki Gülcü
-
- March 2002
-
-Abstract
@@ -37,7 +46,7 @@ Abstract
are output with arbitrary granularity. It is fully configurable at
runtime using external configuration files. Best of all, log4j has a
gentle learning curve. Beware: judging from user feedback, it is also
-quite addictive.
+quite addictive.
Introduction
@@ -47,19 +56,19 @@ Introduction
own tracing API. This was in early 1996. After countless enhancements,
several incarnations and much work that API has evolved to become
log4j, a popular logging package for Java. The package is distributed
-under the Apache Software License, a
+under the Apache Software License, a
fully-fledged open source license certified by the open source initiative. The
latest log4j version, including full-source code, class files and
documentation can be found at http://jakarta.apache.org/log4j/.
-By the way, log4j has been ported to the C, C++, C#, Python, Ruby, and
-Eiffel languages.
+href="http://logging.apache.org/log4j/">http://logging.apache.org/log4j/.
+By the way, log4j has been ported to the C, C++, C#, Perl, Python,
+Ruby, and Eiffel languages.
Introduction
intervention. Moreover, log output can be saved in persistent medium
to be studied at a later time. In addition to its use in the
development cycle, a sufficiently rich logging package can also be
-viewed as an auditing tool.
+viewed as an auditing tool.
-
As personal choice, we tend not to use debuggers beyond getting a
@@ -84,13 +93,13 @@
+
Introduction
the critical section of code, even assuming we know where that
is. More important, debugging statements stay with the program;
debugging sessions are transient.
-Loggers, Appenders and Layouts
@@ -98,7 +107,7 @@ Loggers, Appenders and Layouts
appenders and layouts. These three types of
components work together to enable developers to log messages according
to message type and level, and to control at runtime how these
-messages are formatted and where they are reported.
+messages are formatted and where they are reported.
Logger hierarchy
@@ -112,225 +121,232 @@ Logger hierarchy
package. However, since log4j version 1.2, Logger class
has replaced the Category class. For those familiar with
earlier versions of log4j, the Logger class can be
-considered as a mere alias to the Category class.
+considered as a mere alias to the Category class.
-
+
-
+
-
-"com.foo" is a parent
of the logger named "com.foo.Bar". Similarly,
"java" is a parent of "java.util" and an
ancestor of "java.util.Vector". This naming scheme
-should be familiar to most developers.
+should be familiar to most developers.
-
+
+
+
-
package org.apache.log4j;
-
+
public class Logger {
-
- // Creation & retrieval methods:
+
+ // Creation & retrieval methods:
public static Logger getRootLogger();
public static Logger getLogger(String name);
-
+
// printing methods:
+ public void trace(Object message);
public void debug(Object message);
public void info(Object message);
public void warn(Object message);
public void error(Object message);
+ public void fatal(Object message);
// generic printing method:
public void log(Level l, Object message);
}
Loggers may be assigned levels. The set of possible
-levels, that is
+levels, that is:
-DEBUG,
-INFO,
-WARN,
-ERROR and
-FATAL
+TRACE,
+DEBUG,
+INFO,
+WARN,
+ERROR and
+FATAL
+
are defined in the org.apache.log4j.Level
-class. Although we do not encourage you from doing so, you may define
+href="apidocs/org/apache/log4j/Level.html">org.apache.log4j.Level
+class. Although we do not encourage you to do so, you may define
your own levels by sub-classing the Level class. A
-perhaps better approach is will be explained later on.
+perhaps better approach will be explained later on.
If a given logger is not assigned a level, then it inherits one from its closest ancestor with an assigned level. More -formally: +formally:
| + |
|
To ensure that all loggers can eventually inherit a level, -the root logger always has an assigned level. +the root logger always has an assigned level.
Below are four tables with various assigned level values and the -resulting inherited levels according to the above rule. +resulting inherited levels according to the above rule.
| Logger name | Assigned level |
- Inherited level |
|---|---|---|
| root | Proot | Proot |
| X | none | Proot |
| X.Y | none | Proot |
| X.Y.Z | none | Proot |
In example 1 above, only the root logger is assinged a +
In example 1 above, only the root logger is assigned a
level. This level value, Proot, is inherited by the
other loggers X, X.Y and
-X.Y.Z.
+X.Y.Z.
| Logger name | Assigned level |
- Inherited level |
|---|---|---|
| root | Proot | Proot |
| X | Px | Px |
| X.Y | Pxy | Pxy |
| X.Y.Z | Pxyz | Pxyz |
In example 2, all loggers have an assigned level value. There -is no need for level inheritence. +is no need for level inheritence.
| Logger name | Assigned level |
- Inherited level |
|---|---|---|
| root | Proot | Proot |
| X | Px | Px |
| X.Y | none | Px |
| X.Y.Z | Pxyz | Pxyz |
In example 3, the loggers root, X and
X.Y.Z are assigned the levels Proot,
Px and Pxyz respectively. The logger
X.Y inherits its level value from its parent
-X.
-
-
| Logger name | Assigned level |
- Inherited level |
|---|---|---|
| root | Proot | Proot |
| X | Px | Px |
| X.Y | none | Px |
| X.Y.Z | none | Px |
| Logger name | Assigned level |
+ Inherited level |
|---|---|---|
| root | Proot | Proot |
| X | Px | Px |
| X.Y | none | Px |
| X.Y.Z | none | Px |
In example 4, the loggers root and X
and are assigned the levels Proot and Px
respectively. The loggers X.Y and X.Y.Z
inherits their level value from their nearest parent X
-having an assigned level..
+having an assigned level..
Logging requests are made by invoking one of the printing methods
-of a logger instance. These printing methods are
+of a logger instance. These printing methods are
-debug,
+debug,
-info,
+info,
-warn,
-error,
-fatal
- and log.
+warn,
+error,
+fatal
+ and log.
By definition, the printing method determines the level of a
logging request. For example, if c is a logger
instance, then the statement c.info("..") is a logging
-request of level INFO.
+request of level INFO.
A logging request is said to be enabled if its level is higher than or equal to the level of its logger. Otherwise, the request is said to be disabled. A logger without an assigned level will inherit one from the hierarchy. This rule is -summarized below. +summarized below.
This rule is at the heart of log4j. It assumes that levels are
ordered. For the standard levels, we have DEBUG < INFO
-< WARN < ERROR < FATAL.
+< WARN < ERROR < FATAL.
Here is an example of this rule. +
Here is an example of this rule.
@@ -339,45 +355,46 @@ Logger hierarchy// get a logger instance named "com.foo" Logger logger = Logger.getLogger("com.foo"); - // Now set its level. Normally you do not need to set the - // level of a logger progamitcally. This is usually done + // Now set its level. Normally you do not need to set the + // level of a logger programmatically. This is usually done // in configuration files. logger.setLevel(Level.INFO); Logger barlogger = Logger.getLogger("com.foo.Bar"); - + // This request is enabled, because WARN >= INFO. logger.warn("Low fuel level."); - + // This request is disabled, because DEBUG < INFO. - logger.debug("Starting search for nearest gas station."); - + logger.debug("Starting search for nearest gas station."); + // The logger instance barlogger, named "com.foo.Bar", - // will inherit its level from the logger named - // "com.foo" Thus, the following request is enabled - // because INFO >= INFO. - barlogger.info("Located nearest gas station."); + // will inherit its level from the logger named + // "com.foo" Thus, the following request is enabled + // because INFO >= INFO. + barlogger.info("Located nearest gas station."); // This request is disabled, because DEBUG < INFO. - barlogger.debug("Exiting gas station search"); + barlogger.debug("Exiting gas station search"); - |
Calling the getLogger method with the same name will
-always return a reference to the exact same logger object.
+always return a reference to the exact same logger object.
For example, in +
For example, in
Logger x = Logger.getLogger("wombat");
Logger y = Logger.getLogger("wombat");
- |
+
x and y refer to exactly the same
-logger object.
+logger object.
Thus, it is possible to configure a logger and then to retrieve the same instance somewhere else in the code without passing around @@ -385,11 +402,11 @@
Configuration of the log4j environment is typically done at application initialization. The preferred way is by reading a -configuration file. This approach will be discussed shortly. +configuration file. This approach will be discussed shortly.
Log4j makes it easy to name loggers by software component. This can be accomplished by statically instantiating @@ -400,10 +417,10 @@
Nevertheless, naming loggers after the class where they are -located seems to be the best strategy known so far. +located seems to be the best strategy known so far.
More than one appender can be attached to a logger. +href="apidocs/org/apache/log4j/net/SyslogAppender.html">Syslog +daemons. It is also possible to log asynchronously.
+ +More than one appender can be attached to a logger.
The addAppender
+href="apidocs/org/apache/log4j/Logger.html#addAppender(org.apache.log4j.Appender)">addAppender
method adds an appender to a given logger.
Each enabled logging
@@ -440,64 +457,64 @@ Appenders and Layouts
C's children will print on a file and on the
console. It is possible to override this default behavior so that
appender accumulation is no longer additive by setting
-the additivity flag to false.
+href="apidocs/org/apache/log4j/Logger.html#setAdditivity(boolean)">setting
+the additivity flag to false.
The rules governing appender additivity are summarized below. +
The rules governing appender additivity are summarized below.
|
true by default.
+
+The table below shows an example: +
The table below shows an example:
-| Logger Name | Added Appenders | Additivity Flag | Output Targets | Comment - - | ||||
|---|---|---|---|---|---|---|---|---|
| root | A1 | not applicable | A1 + | Logger Name | Added Appenders | Additivity Flag | Output Targets | Comment | +
| root | A1 | not applicable | A1 | The root logger is anonymous but can be accessed with the Logger.getRootLogger() method. There is no default appender - attached to root. + attached to root. | ||||
| x | A-x1, A-x2 | true | A1, A-x1, A-x2 - | Appenders of "x" and root. + | ||||
| x | A-x1, A-x2 | true | A1, A-x1, A-x2 | +Appenders of "x" and root. | ||||
| x.y | none | true | A1, A-x1, A-x2 - | Appenders of "x" and root. + | ||||
| x.y | none | true | A1, A-x1, A-x2 | +Appenders of "x" and root. | ||||
| x.y.z | A-xyz1 | true | A1, A-x1, A-x2, A-xyz1 - | Appenders in "x.y.z", "x" and root. + | ||||
| x.y.z | A-xyz1 | true | A1, A-x1, A-x2, A-xyz1 | +Appenders in "x.y.z", "x" and root. | ||||
| security | A-sec | false - | A-sec + | |||||
| security | A-sec | false | +A-sec | No appender accumulation since the additivity flag is set to
- false.
+ false. | ||||
| security.access | none | true | A-sec | Only + | ||||
| security.access | none | true | A-sec | Only
appenders of "security" because the additivity flag in "security" is
- set to false.
+ set to false. |
printf function.
+printf function.
For example, the PatternLayout with the conversion pattern "%r [%t]
-%-5p %c - %m%n" will output something akin to:
+%-5p %c - %m%n" will output something akin to:
176 [main] INFO org.foo.Bar - Located nearest gas station. -+
The first field is the number of milliseconds elapsed since the start of the program. The second field is the thread making the log request. The third field is the level of the log statement. The fourth field is the name of the logger associated with the log -request. The text after the '-' is the message of the statement. +request. The text after the '-' is the message of the statement.
Just as importantly, log4j will render the content of the log
message according to user specified criteria. For example, if you
frequently need to log Oranges, an object type used in
your current project, then you can register an
OrangeRenderer that will be invoked whenever an orange
-needs to be logged.
+needs to be logged.
Object rendering follows the class hierarchy. For example, assuming
oranges are fruits, if you register an FruitRenderer, all
fruits including oranges will be rendered by the
FruitRenderer, unless of course you registered an orange
-specific OrangeRenderer.
+specific OrangeRenderer.
Object renderers have to implement the -ObjectRenderer -interface. +ObjectRenderer +interface.
The log4j environment is fully configurable programmatically. However, it is far more flexible to configure log4j using configuration files. Currently, configuration files can be written in -XML or in Java properties (key=value) format. +XML or in Java properties (key=value) format.
Let us give a taste of how this is done with the help of an
-imaginary application MyApp that uses log4j.
+imaginary application MyApp that uses log4j.
@@ -570,7 +587,7 @@- |
MyApp begins by importing log4j related classes. It
then defines a static logger variable with the name
MyApp which happens to be the fully qualified name of the
-class.
+class.
MyApp uses the Bar class defined in the
-package com.foo.
+package com.foo.
package com.foo;
import org.apache.log4j.Logger;
-
+
public class Bar {
static Logger logger = Logger.getLogger(Bar.class);
-
+
public void doIt() {
- logger.debug("Did it again!");
+ logger.debug("Did it again!");
}
}
- |
The invocation of the BasicConfigurator.configure +href="apidocs/org/apache/log4j/BasicConfigurator.html#configure()">BasicConfigurator.configure method creates a rather simple log4j setup. This method is hardwired to add to the root logger a +href="apidocs/org/apache/log4j/ConsoleAppender.html"> ConsoleAppender. The output will be formatted using a PatternLayout set -to the pattern "%-4r [%t] %-5p %c %x - %m%n". +href="apidocs/org/apache/log4j/PatternLayout.html">PatternLayout set +to the pattern "%-4r [%t] %-5p %c %x - %m%n".
Note that by default, the root logger is assigned to
-Level.DEBUG.
+Level.DEBUG.
The output of MyApp is:
0 [main] INFO MyApp - Entering application. 36 [main] DEBUG com.foo.Bar - Did it again! 51 [main] INFO MyApp - Exiting application. -+
The figure below depicts the object diagram of MyApp
after just having called the BasicConfigurator.configure
-method.
+method.
-
+
As a side note, let me mention that in log4j child loggers link
only to their existing ancestors. In particular, the logger named
com.foo.Bar is linked directly to the root
logger, thereby circumventing the unused com or
com.foo loggers. This significantly increases
-performance and reduces log4j's memory footprint.
+performance and reduces log4j's memory footprint.
The MyApp class configures log4j by invoking
BasicConfigurator.configure method. Other classes only
need to import the org.apache.log4j.Logger class,
-retrieve the loggers they wish to use, and log away.
+retrieve the loggers they wish to use, and log away.
The previous example always outputs the same log information.
Fortunately, it is easy to modify MyApp so that the log
output can be controlled at run-time. Here is a slightly modified
-version.
+version.
@@ -666,46 +685,47 @@+ |
This version of MyApp instructs
PropertyConfigurator to parse a configuration file and
-set up logging accordingly.
+set up logging accordingly.
Here is a sample configuration file that results in exactly same
-output as the previous BasicConfigurator based example.
+output as the previous BasicConfigurator based example.
# Set root logger level to DEBUG and its only appender to A1. log4j.rootLogger=DEBUG, A1 - -# A1 is set to be a ConsoleAppender. + +# A1 is set to be a ConsoleAppender. log4j.appender.A1=org.apache.log4j.ConsoleAppender - + # A1 uses PatternLayout. log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n- |
XMLLayout format.
- JDBCAppender by Thomas Fenner. Note
- that log4j 1.2 ships with another JDBCAppender
- written by Kevin Steppe.
- Log4r features an extremely flexible logging library for - Ruby. Killer features include a heiarchial logging system - of any number of levels, logger inheritance, multiple - output destinations, tracing, custom formatting and more. - Log4r was inspired by log4j. Log4r provides the defining - features of log4j and some of its own features that just - might make log4j users envious.
-If you would like your software to be listed here, then send a note to the log4j-user@jakarta.apache.org - list.
- -BEWARE: For some reason Internet Explorer decides to
- rename ".tar.gz" files as ".tar". You should rename the files back to
- tar.gz after the download completes.
-
The project history gives a - brief summary of changes and additions. Users frequently - report bugs that are solved in newer versions of log4j. Please - have a look at the history file before asking for help. -
- -The project's official URL is http://jakarta.apache.org/log4j. -
- -Many thanks to all the log4j users who keep sending us input - and sometimes even praise for our collective effort. The first - ancestor of log4j was written for the E.U. sponsored SEMPER project. N. Asokan, - Ceki Gülcü and Michael Steiner came up with the idea - of hierarchical loggers back in 1996. Their idea is still - at the heart of log4j. The package was considerably improved - over the years at the IBM Zurich Research - Laboratory. However, log4j is no longer associated nor - supported by IBM. -
- -Special thanks to M. Niksch from ZRL for his assistance on - many large and small matters. The Apache members, Pier - Fumagalli and Sam Ruby in particular, have been extremely - helpful in easing the move to Apache. -
- -The log4j logo was designed and kindly donated by
of Switzerland.
-
Inserting log statements into your code is a low-tech method - for debugging it. It may also be the only way because - debuggers are not always available or applicable. This is - often the case for distributed applications.
- -On the other hand, some people argue that log statements - pollute source code and decrease legibility. (We believe that - the contrary is true). In the Java language where a - preprocessor is not available, log statements increase the - size of the code and reduce its speed, even when logging is - turned off. Given that a reasonably sized application may - contain thousands of log statements, speed is of particular - importance.
- - -With log4j it is possible to enable logging at runtime - without modifying the application binary. The log4j package is - designed so that these statements can remain in shipped code - without incurring a heavy performance cost. Logging behavior - can be controlled by editing a configuration file, without - touching the application binary.
- -Logging equips the developer with detailed context for - application failures. On the other hand, testing provides - quality assurance and confidence in the application. Logging - and testing should not be confused. They are - complementary. When logging is wisely used, it can prove to be - an essential tool.
- -One of the distinctive features of log4j is the notion of - inheritance in loggers. Using a logger - hierarchy it is possible to control which log - statements are output at arbitrarily fine granularity but also - great ease. This helps reduce the volume of logged output and - minimize the cost of logging.
- -The target of the log output can be a file, an
- OutputStream, a java.io.Writer, a
- remote log4j server, a remote Unix Syslog daemon, or even a NT
- Event logger among many other output targets.
On a 233 MHz ThinkPad running JDK 1.1.7B, it costs about 46 - nanoseconds to determine if that statement should be logged or - not. Actual logging is also quite fast, ranging from 79 - microseconds using the SimpleLayout, 164 microseconds using - the TTCCLayout and around a millisecond when printing - exceptions. The performance of the PatternLayout is almost as - good as the dedicated layouts, except that it is a lot more - flexible.
- -The package is being constantly improved thanks to input from - users and code contributed by authors in the community. -
- -The following paragragh was adapted from the Cactus - project's roadmap with the author's permission. -
- -Our users keep inventing better ways and adding new - requirements. The downside is that our todo list keeps - growing. The upside is that there is plenty of work to go - around. If you are interested in participating, send an email - on the log4j-dev@ mailing list stating your interest. You'll - be promptly enrolled. We're always looking for help! Don't be - put off if in the "Volunteer" column already has a person - listed. Programming is fun, especially if it is done in a - team. -
- -- -
- - -With log4j 1.2 still in beta, the workplan for log4j 1.3 is - obviously not final. It is included here to give you an idea - of the future. The items are not listed in any particular - order. -
- -| Label | -Comment | -Volunteer | -Status | -
|---|---|---|---|
| test cases | - -
- Writing test cases is not the most sexy part of - software development but it is one of the most - important. Automated test cases allow us to catch bugs - as early is possible. It is strongly recommended to add - a new test case with each new feature or component. - -Existing Perl language based test cases are
- gradually being migrated to junit (all-Java)based test
- cases. The new tests are placed under the
- |
-
- All committers | -ongoing effort | -
| Extensible XML configuration files | - -
- The DOMConfigurator is complex and not very - flexible. It can only deal with elements that the - developer knew about at compilation time. This has been - an important drawback in the design of several appenders - such as the the SMTPAppender and the - RollingFileAppenders and its variants. These appenders - need to delegate certain task to sub-components which - are configured separately. - - -The support for extensible configuration files will be - based on the code in commons-digester authored by Craig - McClanahan and Scott Sanders. They graciously granted - permission for the modification of their code and its - inclusion in log4j. - |
- Ceki | -design board | -
| Log4j Domains | - -
- This is a very powerful and innovative concept that - extends the notion of hierarchical loggers. It will also - allow dynamic logging with pin-point accuracy. It was - first suggested to me by Scott Stark of JBoss fame. - - |
- Ceki | -design board | -
| Multiple implementations of Logger | - -
- Based on |
-
-
- ? | -vaporware | -
| Improvements to Chainsaw | - -
- Visualisation and dynamic filtering of logging event is - bound to be a very important area of activity in the - future. A number of important improvements to chainsaw - have been suggested. - - - |
- Oliver Burn | -under discusison | -
| 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. | - -? | -not started | -
| Overture to other programming languages | - -It is higly desriable to allow log4j ports in other languages - to access log4j services in a language independent way. - | - -? | -not started | -
| Strategy based rollovers | - -
- Contrary to our own DailyRollingFileAppender, Avalon's
- logkit has a nice and clean implementation for rolling
- files. See the
- Their implementation is based on strategies which are - sub-components of appender. We will be able to configure - such sub-components with the new XML configuration - scripts. - - |
- Kevin Steppe | -not started | -
| Redesign of configure and watch architecture in - configurators | - -This is a very useful feature and the current architecture is not very good.
-
- Contributions have been received by Mark Womack and others. - -See - - http://www.mail-archive.com/log4j-dev@jakarta.apache.org/msg01390.html - http://www.mail-archive.com/log4j-user@jakarta.apache.org/msg00666.html - http://marc.theaimsgroup.com/?t=101010070500002&r=1&w=2 -- - |
- Mark Womack | -initial implementation | -
| Performance improvements to LoggingEvent serialization | - -
- Ole Dalgaard has shown that by implementing the - java.io.Externalizable interface instead of - java.io.Serializable in the LoggingEvent class, the - speed of serialiazation is increased by a factor of 4 or - more. - - - |
- Ole Dalgaard? | -initial implementation | -
- Here is workplan for the 1.2 release. As always, there is no - scheduled release date. The lack of schedule suprises and - disturbs some people. Writing good software, like good - cooking, takes time. If we make you wait, it is to create a - better and more reliable product. -
- -| Label | -Comment | -Volunteer | -Status | -
|---|---|---|---|
| More test cases | - -We need more automated test cases to catch bugs as early - is possible.It is highly recommended to add a new test case - with each new feature or component. | - -All committers | -ongoing effort | -
| Removal of deprecated methods | - -Deprecated setOption and getOption
- methods in appender and layouts should be removed. |
-
- Ceki | -done | -
| JDBCAppender | - -
- We currently have two competing JDBCAppenders: one by - Thomas Fenner and the other by Kevin Steppe. - -Kevin Steppe stood up and did it. - |
-
- Kevin Steppe | - -done | -
| Log4j in applets | - -In order to minimize network traffic, the size of log4j-core.jar
- needs to be reduced to at most 50KB.
-
- Log4jME has been released. It's less than 20KB. - |
-
- Ceki | -done | -
| Improved documentation | - -Log4j documentation needs to be enhanced with configuration - examples and much more hand-holding. | - -Ceki | - -ongoing effort | - -
| Mapped Diagnostic Contexts | - -Mapped Diagnostic Contexts are similar to the NDC
- except that the MDC is a string to string map instead of
- a stack that the user sets when entering a special
- context. The PatternLayout has to be
- enhanced to support this by extending the %x pattern to
- accept an argument. Here is an example:
-
-
- ConversionPattern=3D%d %p %c %x{server} %x{host} - %m%n
-
-
- User code:
-
- {
- MDC.put("server", "totoServer");
- MDC.put("host", "someHost");
-
- logger.debug("Hello");
-
- }
-
- will print:
- 2000-01-24 10:00:00,000 DEBUG totoServer someHost - Hello- - To make MDCs truly user friendly
- |
- Ceki | -done | -
| Enhanced variable substitution support in DOMConfigurator | -- - | Ceki | -done | -
| FallbackErrorHandler | - -The FallbackErrorHandler implements the ErrorHandler
- interface such that a secondary appender may be
- specified. This secondary appender takes over if the primary
- appender fails for whatever reason.
-
- The DOMConfigurator needs to be extended to support the - FallbackErrorHandler - - |
- Ceki | -implemented, requires further testing | -
| Ensure backward compatibility of LoggingEvent - objects | - -To avoid deployment problems we must ensure that
- LoggingEvent objects are compatible between 1.2 and 1.1.3.
-
- Robert Bushman has proposed a very innovative way for - solving this problem. See - http://www.mail-archive.com/log4j-dev@jakarta.apache.org/msg01397.html - for further details. - - |
-
- Ceki | -implemented, manually tested, requires automated test cases | -
As of version 0.8 of the JSR47 specification the
- java.util.logging API resembles log4j even more
- than was the case previously. The way the two APIs name their
- components may differ but otherwise their degree of
- resemblance is quite striking.
-
Changes introduced in the latest 0.8 draft include - configuration order independence, appender inheritance, - resource bundle inheritance, error handlers and lazy inference - of caller information. In other words, even if the priority - levels remain unchanged and somewhat bogus, the majority of - the points raised in my critique - of JSR47 are now obsolete. -
- -Consequently, it is fair to say that our campaign to - influence the JSR47 API handsomely bore fruit. I wish to thank - the hundreds of concerned users who have expressed their - support for log4j. My gratitude goes to Jason Hunter for - arranging the appropriate communication channel to Sun. Graham - Hamilton, the JSR47 specification lead, was very open and - receptive during our exchanges. -
- -From the user standpoint, there remain two critical - differences. First, JSR47 requires JDK 1.4 whereas log4j is - compatible with JDK 1.1 and later. Second, log4j offers much - more functionality. It supports a rich configuration language, - at least a dozen appenders and layouts as well as many other - useful features.
- -Efforts to backport JSR47 to earlier JDKs are doomed to fail
- because the java.util.logging package is located
- under the java namespace. This will cause
- backported code to systematically throw a
- SecurityException under JDK 1.3. Moreover, Java
- is a trademark owned by Sun Microsystems. As such, the
- backported code will be under the threat of litigation as long
- as Sun can be expected to defend its trademark.
-
If you take the time to study the terms of the final draft of - the JSR47 specification, you will discover a copyright notice - containing the following text.
- -- - Sun hereby grants you a fully-paid, non-exclusive, non-transferable, - worldwide, limited license (without the right to sublicense), under - Sun's intellectual property rights that are essential to practice - the Specification, to internally practice the Specification solely - for the purpose of creating a clean room implementation of the - Specification that: (i) includes a complete implementation of - the current version of the Specification, without subsetting or - superset-ting; (ii) implements all of the interfaces and - functionality of the Specification, as defined by Sun, without - sub-setting or supersetting; (iii) includes a complete - implementation of any optional components (as defined by Sun in the - Specification) which you choose to implement, without subsetting or - supersetting; (iv) implements all of the interfaces and - functionality of such optional components, without subsetting or - supersetting; (v) does not add any additional packages, - classes or interfaces to the "java.*" or "javax.*" packages or - subpackages (or other pack-ages defined by Sun); (vi) - satisfies all testing requirements available from Sun relating to - the most recently pub-lished version of the Specification six (6) - months prior to any release of the clean room implementation or - upgrade thereto; (vii) does not derive from any Sun source - code or binary code materials; and (viii) does not include - any Sun source code or binary code materials without an appropriate - and separate license from Sun. The Specification contains the - proprietary information of Sun and may only be used in accordance - with the license terms set forth herein. This license will terminate - immediately without notice from Sun if you fail to comply with any - provision of this license. Upon termination or expiration of this - license, you must cease use of or destroy the Specification. -- -
Given these business terms it is not possible for log4j or - other independent parties to implement the JSR47 - specification. Here is how the Apache Software foundation, a - member of the JCP Executive Committee, voted on this - JSR.
- -- - The Apache Software Foundation is grateful for the significant - efforts of the JSR 47 spec lead, Graham Hamilton, toward addressing - the technical concerns raised by the members and lead of Apache's - log4j project. Regretfully, under the Merlin business terms, log4j - (or any other potential independent implementation of this - specification) cannot make use of the Specification, not can anyone - implement this specification for earlier J2SE platforms (J2SE 1.2, - 1.3), and it is on this basis that Apache cannot support this JSR. -- -
This problems is not specific to JSR47. Most other JSR - specifications contain similar business terms which are not - exactly designed to facilitate independent implementations. -
- -Log4j is the de facto standard logging API in Java. It has - been ported to Python, Ruby, C, C++, Eiffel and the much - maligned C#. By adopting log4j, you simultaneously benefit - from much richer functionality and wider JDK - compatibility. With the support of the log4j community, the - log4j project will continue to innovate and lead the way. As - such, many of the features that you need will be first - available in log4j.
- -There are many other details in which log4j differs from - JSR47. Even if the log4j core is small, the project contains a - total of over 30'000 lines of well-tested code. JSR47 contains - about 5'000 lines of code. -
- -It is likely that you will need an additional logging library - to fill in the functionality gap, the JDK compatibility gap, - or both. If you are going to install one or more logging APIs, - then why not install log4j which offers a lot more than JSR47 - and is backward compatible with JDK 1.1? -
- -Log4j has been around for a number of years, enjoys the - support of an active community and is being used in thousands - of projects. Our site gets over 600 downloads each and every - day, and the numbers are on the rise. Companies are also - offering commercial products extending log4j. -
- -Here is a short list of open source projects or sites that are - known to use log4j.
- -Sun is setting a dangerous precedent by ignoring a rather - successful open source project. If it happens to log4j, can it - happen to other open source projects?
- -If you feel that Sun is reinventing the wheel and setting a - dangerous precedent, then this the time to ask Sun to adopt - log4j as the official logging API for the Java language.
- -Please direct your polite and personalized request to jsr-47-comments@jcp.org with Bcc: to ceki@apache.org. -
- -Many individuals have written to Sun to express their - concern, in their vast majority pushing for the adoption of - log4j. Their names and the content of their request are listed - below. We are very grateful for their support. Some of these - requests are quite detailed and insightful. -
- -Most of the e-mail notes are reproduced with - permission. However, do not hesitate to contact ceki@apache.org in case you are - uncomfortable seeing your name or the contents of your request - reproduced publicly.
-