org.elasticsearch.common.logging.LogConfigurator Java Examples

The following examples show how to use org.elasticsearch.common.logging.LogConfigurator. 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: CrateDB.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Main entry point for starting crate
 */
public static void main(final String[] args) throws Exception {
    LogConfigurator.registerErrorListener();
    final CrateDB crate = new CrateDB();
    int status = main(args, crate, Terminal.DEFAULT);
    if (status != ExitCodes.OK) {
        exit(status);
    }
}
 
Example #2
Source File: CommandLoggingConfigurator.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Configures logging without Elasticsearch configuration files based on the system property "es.logger.level" only. As such, any
 * logging will be written to the console.
 */
public static void configureLoggingWithoutConfig() {
    // initialize default for es.logger.level because we will not read the log4j2.properties
    final String loggerLevel = System.getProperty("es.logger.level", Level.INFO.name());
    final Settings settings = Settings.builder().put("logger.level", loggerLevel).build();
    LogConfigurator.configureWithoutConfig(settings);
}
 
Example #3
Source File: PluginAwareNode.java    From deprecated-security-ssl with Apache License 2.0 4 votes vote down vote up
@Override
protected void registerDerivedNodeNameWithLogger(String nodeName) {
    System.out.println("nn "+nodeName);
    LogConfigurator.setNodeName(nodeName);
}
 
Example #4
Source File: LicenseTool.java    From crate with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    LogConfigurator.configureWithoutConfig(Settings.EMPTY);
    OptionParser parser = new OptionParser();
    ArgumentAcceptingOptionSpec<String> keyArg = parser.accepts("key", "Path to private key")
        .withRequiredArg()
        .ofType(String.class);
    ArgumentAcceptingOptionSpec<String> expirationDateArg = parser.accepts("expiration-date")
        .withRequiredArg()
        .ofType(String.class);
    ArgumentAcceptingOptionSpec<String> issuedToArg = parser.accepts("issued-to")
        .withRequiredArg()
        .ofType(String.class);
    ArgumentAcceptingOptionSpec<Integer> maxNodesArg = parser.accepts("max-nodes")
        .withRequiredArg()
        .ofType(Integer.class);

    String keyPath;
    long expirationDate;
    String issuedTo;
    int maxNodes;
    try {
        OptionSet optionSet = parser.parse(args);
        keyPath = keyArg.value(optionSet);
        expirationDate = DataTypes.TIMESTAMPZ.value(expirationDateArg.value(optionSet));
        issuedTo = issuedToArg.value(optionSet);
        maxNodes = maxNodesArg.value(optionSet);
        if (maxNodes <= 0) throw new IllegalArgumentException("max-nodes needs to be a positive number");
    } catch (Exception e) {
        parser.printHelpOn(System.err);
        System.exit(1);
        return;
    }

    byte[] keyBytes = Files.readAllBytes(Paths.get(keyPath));
    PrivateKey privateKey = KeyFactory.getInstance(CryptoUtils.RSA_CIPHER_ALGORITHM)
        .generatePrivate(new PKCS8EncodedKeySpec(keyBytes));

    byte[] licenseData = LicenseConverter.toJson(new LicenseData(expirationDate, issuedTo, maxNodes));
    byte[] encryptedLicenseData = CryptoUtils.crypto(
            CryptoUtils.RSA_CIPHER_ALGORITHM,
            Cipher.ENCRYPT_MODE,
            privateKey,
            licenseData);
    LicenseKey licenseKey = LicenseKey.encode(License.Type.ENTERPRISE, 2, encryptedLicenseData);
    System.out.println(licenseKey.licenseKey());
}