Skip to content

Instantly share code, notes, and snippets.

ishults / example.groovy
Created Sep 24, 2017
Invoking the log marker
View example.groovy, '{"ssn": "1234567890"}') // Will mask'{"ssn": "1234567890"}') // Will NOT mask, '{"ssn": "1234567890"}') // Will try to mask, but probably won't work for this message
ishults / log4j2.xml
Created Sep 24, 2017
Log4J 2 configuration
View log4j2.xml
<Configuration packages=', com.your.other.packages'>
<Property name="maskingPattern">
%d, level=%p, %cm
ishults / LoggingMarkers.groovy
Last active Jan 11, 2021
The logging markers for Log4j
View LoggingMarkers.groovy
class LoggingMarkers {
static final Marker JSON = MarkerFactory.getMarker('JSON-MASK')
static final Marker XML = MarkerFactory.getMarker('XML-MASK')
ishults / LogMaskingConverterSpec.groovy
Last active Sep 26, 2017
Tests for the main class
View LogMaskingConverterSpec.groovy
class LogMaskingConverterSpec extends Specification {
LogMaskingConverter converter
void setup() {
converter = new LogMaskingConverter()
ishults / LogMaskingConverter.groovy
Last active Sep 24, 2017
The class that will handle filtering the log statements
View LogMaskingConverter.groovy
@Plugin(name = 'logmask', category = 'Converter')
class LogMaskingConverter extends LogEventPatternConverter {
private static final String NAME = 'cm'
private static final String JSON_REPLACEMENT_REGEX = "\"\$1\": \"****\""
private static final String JSON_KEYS = ['ssn', 'private', 'creditCard'].join('|')
private static final Pattern JSON_PATTERN = Pattern.compile(/"(${JSON_KEYS})": "([^"]+)"/)
LogMaskingConverter(String[] options) {
super(NAME, NAME)
ishults / pom.xml
Last active Sep 24, 2017
View pom.xml
ishults / garage_door.yaml
Last active Aug 29, 2016
Garage door signal script
View garage_door.yaml
# turn_on closes the circuit, so always send it to "toggle"
- service: switch.turn_on
entity_id: switch.fortrezz_unknown_type0453_id0111_switch_1
View ssl_default
server {
listen 80;
server_name; # Your site
rewrite ^ https://$host$request_uri permanent;
server {
listen 443 default_server ssl;
server_name; # Your site
View cron
crontab -e
# Add this. x is the minute of renewal, while y and z are the hours.
# You can (should) move the command into a script and run that.
x y,z * * * sudo service nginx stop && letsencrypt renew --quiet && sudo service nginx start