Java Code Examples for ch.qos.logback.core.Context#getProperty()

The following examples show how to use ch.qos.logback.core.Context#getProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HostNameKeyingStrategy.java    From TarsJava with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void setContext(Context context) {
    super.setContext(context);
    final String hostname = context.getProperty(CoreConstants.HOSTNAME_KEY);
    if (hostname == null) {
        if (!errorWasShown) {
        addError("Hostname could not be found in context. HostNamePartitioningStrategy will not work.");
            errorWasShown = true;
        }
    } else {
        hostnameHash = ByteBuffer.allocate(4).putInt(hostname.hashCode()).array();
    }
}
 
Example 2
Source File: ContextNameKeyingStrategy.java    From TarsJava with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void setContext(Context context) {
    super.setContext(context);
    final String hostname = context.getProperty(CoreConstants.CONTEXT_NAME_KEY);
    if (hostname == null) {
        addError("Hostname could not be found in context. HostNamePartitioningStrategy will not work.");
    } else {
        contextNameHash = ByteBuffer.allocate(4).putInt(hostname.hashCode()).array();
    }
}
 
Example 3
Source File: ExceptionConverter.java    From styx with Apache License 2.0 5 votes vote down vote up
private String[] readStyxClassesFromProperty() {
    String[] targetClasses = TARGET_CLASSES_DEFAULT;
    Context ctx = getContext();
    String property = ctx.getProperty(TARGET_CLASSES_PROPERTY_NAME);
    if (isNotEmpty(property)) {
        targetClasses = stream(property.split(","))
                .map(String::trim)
                .toArray(String[]::new);
    } else {
        addError(MessageFormat.format("The '{0}' property should be present on logback configuration. Using default classname prefixes.",
                TARGET_CLASSES_PROPERTY_NAME));
    }
    return targetClasses;
}
 
Example 4
Source File: AppHostKeyBuilder.java    From SkyEye with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setContext(Context context) {
    super.setContext(context);
    String host = context.getProperty(CoreConstants.HOSTNAME_KEY);
    String app = context.getName();
    appHost = ByteBuffer.allocate(4).putInt(new StringBuilder(app).append(host).toString().hashCode()).array();
}
 
Example 5
Source File: HostNameKeyingStrategy.java    From logback-kafka-appender with Apache License 2.0 5 votes vote down vote up
@Override
public void setContext(Context context) {
    super.setContext(context);
    final String hostname = context.getProperty(CoreConstants.HOSTNAME_KEY);
    if (hostname == null) {
        if (!errorWasShown) {
        addError("Hostname could not be found in context. HostNamePartitioningStrategy will not work.");
            errorWasShown = true;
        }
    } else {
        hostnameHash = ByteBuffer.allocate(4).putInt(hostname.hashCode()).array();
    }
}
 
Example 6
Source File: ContextNameKeyingStrategy.java    From logback-kafka-appender with Apache License 2.0 5 votes vote down vote up
@Override
public void setContext(Context context) {
    super.setContext(context);
    final String hostname = context.getProperty(CoreConstants.CONTEXT_NAME_KEY);
    if (hostname == null) {
        addError("Hostname could not be found in context. HostNamePartitioningStrategy will not work.");
    } else {
        contextNameHash = ByteBuffer.allocate(4).putInt(hostname.hashCode()).array();
    }
}