Giter Club home page Giter Club logo

log4sh's Introduction

log4sh

log4sh is an advanced logging framework for shell scripts (eg. sh, bash) that works similar to the logging products available from the Apache Software Foundataion (eg. log4j, log4perl).

log4sh provides different releases so that users can depend on functionality within a release series. It uses a variant of the X.Y.Z Semantic Versioning system.

  • X -- major release. Significant functionality has changed, and users of the code will definitely require changes to continue using it. These are extremely rare.
  • Y -- minor release. New functionality was added. To maintain stability for users, stable releases are numbered with even numbers (e.g. 1.4), with development releases numbered with odd numbers (e.g. 1.5). Development releases possibly include functionality that breaks backwards compatibility.
  • Z -- patch release. Bug fixes, and minor new functionality that remains 100% backwards compatible.

log4sh was originally hosted on Source Forge as https://sourceforge.net/p/log4sh/. It moved here in Sep 2017 to be hosted alongside the other projects by @kward (https://github.com/kward).

[2021-12-12] log4sh is not Log4Shell. log4sh is written in pure shell code, and does not use Java in any way, shape, or form. It is therefore not vulnerable to the Log4j exploit mentioned in CVE-2021-4428, which is also named Log4Shell or LogJam. For more information, about the unrelated exploit, see https://www.kaspersky.com/blog/log4shell-critical-vulnerability-in-apache-log4j/43124/.

log4sh's People

Contributors

kward avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

log4sh's Issues

Do NOT emit empty log-messages

Use Case:
export logger_info logger_export; scp -p file host:/tmp/file 1> >(logger_info) 2> >(logger_error)

Situation now: even on success of scp , when nothing is written to logger_error, an error-log entry is written.

Desired: on success of scp , when nothing is written to logger_error, write no error-log entry.

Code-Change:

log() {
...
# if no message was passed, read it from STDIN
[ $# -ne 0 ] && l_msg="$@" || l_msg=cat
if [ "" = "${l_msg}" ]; then return; fi

Install steps are not as documented

Thanks for making this tool!

The current README.md file indicates steps to "get started" include downloading source (git clone, for instance?) and running make test-prep. There is no src directory and the make breaks early.

The file generated by build.sh creates a log4sh quite different than log4sh, even though both are versioned '1.5'.

Build fails if directory structure has spaces in directory names

My src directory is in a file structure that has a space in one of the directory names and the Makefile fails.

cp -p /Volumes/Zed/Dir Has Space/src/log4sh/src/shell/log4sh /Volumes/Zed/Dir Has Space /src/log4sh/build
cp: /Volumes/Zed/Dir is a directory (not copied)
cp: Has Space/src/log4sh/src/shell/log4sh: No such file or directory
cp: /Volumes/Zed/Dir is a directory (not copied)
make: *** [build] Error 1

Hello world example gives an error for 'sed' and 'tr'

Hi Team :-)

First of all - I like your project very much. Thank you very much for all your work on this project.

Just tried to do the first baby steps on log4sh starting with the famous 'hello world' example according to doc/log4sh.md.

If I use the preconfigured version, I get the following error message in the function
_appender_parsePattern():

++ : _appender_parsePattern 3 -ne 3 8
++ _app_pattern='%-4r [%t] %-5p %c %x - %m%n'
++ _app_priority=INFO
++ _app_msg='Hello, world'
++ _app_date=
++ _app_doEval=1
++ _app_oldIFS=' '
++ IFS=%
++ set -- x '-4r [' 't] ' '-5p ' 'c ' 'x - ' m n
++ IFS=' '
++ '[' 8 -gt 1 ']'
++ IFS=d
++ set -- '%-4r [%t] %-5p %c %x - %m%nx'
++ IFS=' '
++ '[' 1 -gt 1 ']'
++ IFS=X
++ set -- '%-4r [%t] %-5p %c %x - %m%nx'
++ IFS=' '
++ '[' 1 -gt 1 ']'
+++ echo 'Hello, world'
+++ sed 's/\\/\\\\/g;s/&/\\&/g'
++ _app_msg='Hello, world'
+++ echo 'Hello, world'
+++ tr '\n' ''
tr: when not truncating set1, string2 must be non-empty
++ _app_msg=
+++ echo '%-4r [%t] %-5p %c %x - %m%n'
+++ sed -e s/%c/shell/g -e 's/%d{[^}]*}/%d/g' -e s/%d//g -e s/%F/hello_world/g -e s/%L//g -e s/%n//g -e 's/%-*[0-9]*p/INFO/g' -e 's/%-*[0-9]*r/1/g' -e s/%t/main/g -e s/%x//g -e 's/%X{/$\{/g' -e s/%%m/%%%m/g -e s/%%/%/g -e s%m
+++ tr '' '\n'
sed: -e expression #14, char 3: unterminated `s' command
++ _app_pattern=
++ '[' 1 -eq 1 ']'
++ echo ''
++ unset _app_date _app_doEval _app_msg _app_oldIFS _app_pattern _app_tag
++ return 0
....

These are the version informations:
LOG4SH_VERSION='1.5.1pre'
Linux: RHEL5 2.6.18-419.el5
Bash-Version: 3.2.25(1)-release

The script looks as follows:

#
# log4sh example: Hello, world
#
myDir=`dirname $0`

# Find and source log4sh.
if [ -r "$myDir/log4sh" ]; then
  log4shDir=$myDir
elif [ -r "./log4sh" ]; then
  log4shDir=.
else
  echo "fatal: could not find log4sh" >&2
  exit 1
fi

. $log4shDir/log4sh

# Say Hello to the world.
logger_info 'Hello, world'

And finally the properties file...:

#
# log4sh example: Hello, world properties file
#

# Set root logger level to INFO and its only appender to A1.
log4sh.rootLogger=INFO, A1

# A1 is set to be a ConsoleAppender.
log4sh.appender.A1=ConsoleAppender

# A1 uses a PatternLayout.
log4sh.appender.A1.layout=PatternLayout
log4sh.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

Maybe I just made a misconfiguration (or it's a RHEL issue).
Do you have an idea why this happens?

Kind regards,
Bert99Blib

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.