Java : log syslog avec log4j

package syslog;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.net.SyslogAppender;

public class test {
	private static final Logger log = Logger.getLogger(test.class);

	public static void main(String[] args) {
		Logger rootLogger = Logger.getRootLogger();
		
		rootLogger.setLevel(Level.DEBUG);

		PatternLayout layout = new PatternLayout("%t: %p: %m%n");
		SyslogAppender syslogAppender = new SyslogAppender(layout, "localhost",
				SyslogAppender.LOG_USER);
		
		Logger.getRootLogger().addAppender(syslogAppender);

		log.info("log message");
	}
}

Ne pas oublier d’activer l’écoute réseau du serveur syslog local :

# vim /etc/rsyslog.conf
# provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514

Git : annuler le dernier commit « amend »

# git reset --soft HEAD@{1}

Docker : activer les restrictions RAM & swap

# vim /etc/default/grub 
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
# update-grub
# vim /etc/default/docker
DOCKER_OPTS="--exec-opt native.cgroupdriver=cgroupfs"
# shutdown -r now

Debian : fix startup Docker 1.7 & kernel 4.1

sept. 20 19:34:19 muse systemd[1]: Started Docker Application Container Engine.
sept. 20 19:34:19 muse docker[18643]: time="2015-09-20T19:34:19.773439875+02:00" level=error msg="[graphdriver] prior storage driver \"aufs\" failed: driver not supported"
sept. 20 19:34:19 muse docker[18643]: time="2015-09-20T19:34:19.773487551+02:00" level=fatal msg="Error starting daemon: error initializing graphdriver: driver not supported"
# rm -rf /var/lib/docker/aufs
# systemctl start docker

Debian : fix crash Netbeans 8

# vim /etc/java-8-openjdk/accessibility.properties
#assistive_technologies=org.GNOME.Accessibility.AtkWrapper

Git : appliquer une stratégie de merge différente

# git checkout master
# git merge --no-ff release -X theirs

MongoDB : déployer rapidement un replicat set local

https://github.com/allanbank/mongodb-tricks

https://github.com/allanbank/mongodb-tricks/blob/master/src/main/scripts/replica-set-start.sh

Linux : afficher la consommation swap par processus

# for file in /proc/*/status ; do awk '/^(VmSwap|Pid|Name)/{printf $2 " " $3}END{ print ""}' $file; done | sort

Git : prompt bash

Un prompt bash spécialisé pour l’utilisation de Git :

https://github.com/magicmonty/bash-git-prompt

Linux : tester les performances I/O

# hdparm -t -T /dev/sda
# dd bs=1M count=512 if=/dev/zero of=test conv=fdatasync
# bonnie++ -d /mnt -r 8000 -u toto
Haut de page