Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include log4j2. #162

Merged
merged 4 commits into from
Oct 1, 2020
Merged

Include log4j2. #162

merged 4 commits into from
Oct 1, 2020

Conversation

enozcan
Copy link
Contributor

@enozcan enozcan commented Sep 17, 2020

Closes #129

@enozcan enozcan requested a review from leszko September 17, 2020 13:58
Copy link

@hasancelik hasancelik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@enozcan
Copy link
Contributor Author

enozcan commented Sep 18, 2020

Thanks for the review @hasancelik.
Do you have any idea why the builder does not fail on other architectures but s390x? TBH the logs do not make sense to me: https://travis-ci.org/github/hazelcast/hazelcast-docker/jobs/728021165

EDIT 2:

FYI: I have narrowed the issue down to the logger's layout pattern at our default log4j2.properties. The build passes without the layout pattern provided. Let me try some other patterns.

appender.console.layout.pattern=%d [%highlight{${LOG_LEVEL_PATTERN:-%5p}}{FATAL=red, ERROR=red, WARN=yellow, INFO=green, DEBUG=magenta}] [%style{%t{1.}}{cyan}] [%style{%c{1.}}{blue}]: %m%n

EDIT:

I believe passing properties file is the origin of the problem. Container crashes upon creation:

# CLASSPATH=/opt/hazelcast/*:/opt/hazelcast/lib/*
# starting now....
########################################
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGFPE (0x8) at pc=0x000003ffae71524e (sent by kill), pid=1, tid=7
#
# JRE version: OpenJDK Runtime Environment (11.0.5+10) (build 11.0.5+10-alpine-r0)
# Java VM: OpenJDK 64-Bit Server VM (11.0.5+10-alpine-r0, mixed mode, tiered, compressed oops, parallel gc, linux-s390x)
# Problematic frame:
# V  [libjvm.so+0x495252]  Copy::conjoint_memory_atomic(void const*, void*, unsigned long)+0x27a
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P %E" (or dumping to /opt/hazelcast/core.1)
#
# An error report file with more information is saved as:
# /opt/hazelcast/hs_err_pid1.log
#
# If you would like to submit a bug report, please visit:
#   https://bugs.alpinelinux.org/projects/alpine/issues
#

and removing -Dlog4j.configurationFile=${HZ_HOME}/log4j2.properties jvm opt prevents container from crashing:

# CLASSPATH=/opt/hazelcast/*:/opt/hazelcast/lib/*
# starting now....
########################################
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

Copy link

@leszko leszko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goog job Enes! I really like the new logs!

Added 2 comments.

hazelcast-enterprise/start-hazelcast.sh Outdated Show resolved Hide resolved
hazelcast-enterprise/log4j2.properties Outdated Show resolved Hide resolved
@enozcan
Copy link
Contributor Author

enozcan commented Sep 22, 2020

s390x arch forms a super weird behavior for logging pattern. For instance, I couldn't make it work to print logger names with abbreviations (i.e. [c.h.c.CPSubsystem]). It needs %c{1.} pattern that causes the container to crash on s390x with SIGFPE. Moreover, where [DEBUG][main] is fine, having a space between them [DEBUG] [main] causes it to crash again. I haven't seen any reported issue similar to this but come up with these by trial and error. 🤯

So I have 2 suggestions:

  • Having a common pattern for all archs compatible with s390x.

    • pros: no extra arch dependent work is needed
    • cons: logs will lose abbreviation format for logger names. (i.e.[c.h.c.CPSubsystem] becomes [com.hazelcast.cp.CPSubsystem] vice versa).
  • Changing format via env vars (as we do for logging level) when s390x is detected.

    • pros: other architectures will not be affected by this.
    • cons: some ugly works needed in start.sh

@leszko Do you have any further suggestions? WDYT?

@leszko
Copy link

leszko commented Sep 22, 2020

s390x arch forms a super weird behavior for logging pattern. For instance, I couldn't make it work to print logger names with abbreviations (i.e. [c.h.c.CPSubsystem]). It needs %c{1.} pattern that causes the container to crash on s390x with SIGFPE. Moreover, where [DEBUG][main] is fine, having a space between them [DEBUG] [main] causes it to crash again. I haven't seen any reported issue similar to this but come up with these by trial and error. 🤯

So I have 2 suggestions:

  • Having a common pattern for all archs compatible with s390x.

    • pros: no extra arch dependent work is needed
    • cons: logs will lose abbreviation format for logger names. (i.e.[c.h.c.CPSubsystem] becomes [com.hazelcast.cp.CPSubsystem] vice versa).
  • Changing format via env vars (as we do for logging level) when s390x is detected.

    • pros: other architectures will not be affected by this.
    • cons: some ugly works needed in start.sh

@leszko Do you have any further suggestions? WDYT?

That's all very weird. I'd go with the second option. Because we don't know of anyone even using Hazelcast on s390x, so I'd not adjust anything for that architecture. If it's possible to detect it and use different logging for s390x docker image, then I'd go for that. However, I'm not sure what this ugly works is. Do you already know how this ugly IF will look like?

@enozcan
Copy link
Contributor Author

enozcan commented Sep 22, 2020

Not exactly but something like:

BASE="%d [%highlight{${LOG_LEVEL_PATTERN:-%5p}}{FATAL=red, ERROR=red, WARN=yellow, INFO=green, DEBUG=magenta}]"
ARCH=`arch`

if [[ "$ARCH" == "s390x" ]]; then
  export LOGGING_FORMAT="$BASE [%style{%t{1.}}{cyan}] [%style{%c{1.}}{blue}]: %m%n"
else
  export LOGGING_FORMAT="$BASE[%style{%t{1.}}{cyan}] [%style{%-10c}{blue}]: %m%n"
fi

@leszko
Copy link

leszko commented Sep 22, 2020

Not exactly but something like:

BASE="%d [%highlight{${LOG_LEVEL_PATTERN:-%5p}}{FATAL=red, ERROR=red, WARN=yellow, INFO=green, DEBUG=magenta}]"
ARCH=`arch`

if [[ "$ARCH" == "s390x" ]]; then
  export LOGGING_FORMAT="$BASE [%style{%t{1.}}{cyan}] [%style{%c{1.}}{blue}]: %m%n"
else
  export LOGGING_FORMAT="$BASE[%style{%t{1.}}{cyan}] [%style{%-10c}{blue}]: %m%n"
fi

I think this is ok.

@enozcan
Copy link
Contributor Author

enozcan commented Sep 22, 2020

@leszko The build is now passing. PTAL.

@leszko
Copy link

leszko commented Sep 22, 2020

@leszko The build is now passing. PTAL.

Looks good from my end 👍

Copy link

@hasancelik hasancelik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@enozcan enozcan merged commit daf0aa2 into hazelcast:master Oct 1, 2020
@enozcan enozcan deleted the logger branch October 1, 2020 07:40
hasancelik pushed a commit that referenced this pull request Feb 11, 2021
* Add log4j2 for logging.

* Make log format arch dependent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider including logging libraries (eg. log4j, log4j2, logback)
3 participants