Wednesday, April 1, 2015

log4j2: line separator in header's parameter of PatternLayout

Log4j2 provides a new parameter for PatternLayout:

Parameter name: header
Type: String
Description: the optional header string to include at the top of each log file

With the following log4j2.xml configuration:

1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="20">
    <Appenders>
        <RollingRandomAccessFile name="file" fileName="logs/app.log" filePattern="logs/app-%d_%i.log.gz">
            <PatternLayout>
                <header>
Version: ${env:APP_RELEASE_VERSION}
                </header>
                <pattern>%message%n</pattern>
            </PatternLayout>
            <Policies>
                <OnStartupTriggeringPolicy/>
            </Policies>
        </RollingRandomAccessFile>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <AppenderRef ref="file"/>
        </Root>
    </Loggers>
</Configuration>

Git: undo the last rebase

$ git reflog

f0d821f HEAD@{0}: commit_a
2ea24f8 HEAD@{1}: commit_b
0c3cd49 HEAD@{2}: commit_c
de5b02a HEAD@{3}: commit_d

Suppose that "commit_c" was the head commit of the branch just before the rebase. Let's reset the current branch to this commit:

$ git reset --hard HEAD@{2}

Playing with vim configuration for C++

What I got as a result:


The main features:
  • embedded file system explorer
  • syntax highlighting
  • hotkeys for compiling/running C++ code