apache / apache/logging-log4j2

Missing ANSI Italic Style and Rendering Error in Underline Style

Open
#4,105 6 comments 0 reactions 2 assignees Claimed by @raphaelNguyen View on GitHub
bug layouts
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

## Description

After upgrading to version >= 2.25.0, when rendering ansi, `italic` styling on log message no longer works (triggers a warning that the style italic is invalid) while `underline` styling on log message produces italic effect on rendered text. The warning message includes a stack trace that points to `AnsiEscape.createSequence` failing to create sequence for style name `italic` at the line below in `JAnsiTextRenderer`.

https://github.com/apache/logging-log4j2/blob/76c8bef88a5af15b09420445143e652f4696cab7/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/JAnsiTextRenderer.java#L251

This seems to boil down to https://github.com/apache/logging-log4j2/pull/3070, which rewrites `JAnsiTextRenderer` to use `AnsiEscape` instead of depending on external Jansi library to generate ansi escape sequences. However, the enum `AnsiEscape` differs from the enums in the old external Jansi library in that:
* `AnsiEscape` does not have the `ITALIC` entry.
* `AnsiEscape.UNDERLINE` has the code value of `3` which correspond to `ITALIC`.
* Code value `4` which corresponds to `underline` style seems to not be assigned to any enum value in `AnsiEscape`.

(Style code referenced from https://en.wikipedia.org/wiki/ANSI_escape_code#Select_Graphic_Rendition_parameters)

I'm wondering if this was a bug that existed in `AnsiEscape` from a long time ago that was just never noticed. The enum values from this file seems to have been unchanged for a long time. Thank you for your assistant with this issue.

## Configuration

**Version:** >= 2.25.0

**Operating system:** Windows 11

**JDK:** 17.0.16

## Logs

```
// to be supplied
[Stacktraces, errors, etc. relevant applications logs.]
```

## Reproduction

Will supplement this at a later time.
[An isolated test reproducing the test.
JUnit tests similar to the ones in the code base are extremely appreciated.]

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.