Skip to content

setting priorityNames property on PatternFormatter has no effect #2989

@paultomas

Description

@paultomas

Setting the priorityNames property has no effect on the log output. For example:

 AutoPtr<ConsoleChannel> cChannel(new ConsoleChannel);
 AutoPtr<PatternFormatter> pPF(new PatternFormatter);
 pPF->setProperty("priorityNames", "FATAL,CRITICAL,ERROR,WARN,NOTICE,INFO,DEBUG,TRACE");
 pPF->setProperty("pattern", "%Y-%m-%dT%H:%M:%S.%iZ:%I:%p: %s:  %t");
 AutoPtr<FormattingChannel> pFC(new FormattingChannel(pPF, cChannel));
 Logger::root().setChannel(pFC);
 Logger& logger = Logger::get("TestLogger");

 for (int i = 0; i < 10; ++i) logger.information("Test");

The log output still contains "Information" as the priority vs "INFO".

I looked at the code and can see why - when setting priorityNames, the string is parsed (parsePriorityNames). That routine initializes an array correctly (_priorities) , but that array is never referenced by getPropertyName(), which uses the array priorities (no underscore).

Just change line 274 in PatternFormatter.cpp to:

return _priorities[prio];

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions