https://bz.apache.org/bugzilla/show_bug.cgi?id=58905

            Bug ID: 58905
           Summary: Fix Tomcat.silence() to silence the correct logger and
                    to respect defaults
           Product: Tomcat 9
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: knst.koli...@gmail.com

Noted when reviewing implementation of Tomcat.silence() in relation to Tomcat
unit tests.

Currently Tomcat.addContext() is implemented as following:
[[[
    public Context addContext(Host host, String contextPath, String
contextName,
            String dir) {
        silence(host, contextPath);
        Context ctx = createContext(host, contextPath);
        ctx.setName(contextName);
        ctx.setPath(contextPath);
        ctx.setDocBase(dir);
        ctx.addLifecycleListener(new FixContextListener());

        if (host == null) {
            getHost().addChild(ctx);
        } else {
            host.addChild(ctx);
        }
        return ctx;
    }
]]]

The silence() call attempts to silence the logger for this Context by setting
its log level to Level.WARNING.

The following notes apply to Tomcat class of all current versions
(Tomcat 7/8/9):

1. Note that in Tomcat unit tests the loggers are not silenced by default,
as Tomcat.setSilent(boolean) is not called by Tomcat test code.

=> The silent(Host, contextPath) call shall respect the defaults and do not
silence this logger if other loggers are not silenced.

2. The Engine name used in Tomcat.getLoggerName() is wrong.

Tomcat.getEngine() uses "Tomcat" as the name, not "default".

=> It shall get the actual Engine instance from Host.getParent().

3. Tomcat.getLoggerName() shall use the same logic as ContainerBase.logName()

=> It does not handle "" and null names correctly.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to