I'm trying to configure an extra interface in a wildfly swarm project.
The documentation says you just have to add the following snippets to the project-defaults.yml :
swarm:
network:
interfaces:
backnet:
bind: 192.168.4.5
But this doesn't work. Does anyone know if this is actually implemented?
I can add that setting the logging level to TRACE will output the generated xml configuration that shows only the default public interface and no backnet at all.
EDIT: I'm working with latest "stable" swarm : 2018.1.1
I've found a WA solution so far : add an XML snippets for interfaces:
I have to start the app like this:
java -Dswarm.local.ip=`hostname --ip-address` -jar myapp-swarm.jar -c config.xml
With this XML snippets (config.xml):
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:5.0">
<interfaces>
<interface name="mylocalif">
<inet-address value="${swarm.local.ip}"/>
</interface>
</interfaces>
</server>
This will be merged with the rest of the yaml generated conf and work. I still would like to do everything with YAML though.
Related
I will premise this with the fact that I am new to Symfony but have been using Laravel for some years.
Is it possible to change the format of the log timestamp string through configuration in Symfony (I'm sure it is). I am getting log files out that look like this…
[2022-10-18T09:11:04.228289+00:00] app.DEBUG: a message [] []
I would like to format them like this…
[2022-10-18 09:11:04] app.DEBUG: a message [] []
I am not sure if this is the relevant setting, I suspect it is part of it, but this is the LineFormatter class within Monolog
class LineFormatter extends NormalizerFormatter
{
public const SIMPLE_FORMAT = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
I assume this bit is formatting the timestamp [%datetime%] and is being pulled from a system wide configuration. If this is the case, does anyone know how I can override it?
Using Symfony 6 btw
Thanks in advance
Gary
Welcome on stackoverflow Gary.
Monolog is a library. Symfony imports libraries via a Bundle. You can configure them via the yaml files in the config subdirectory.
To know which options exists, you have three solutions :
Google method. Search the bundle documentation, but in your case, no words about it.
Brutus method: put any value to get an error message. You should see that an option like use_milliseconds exists (I cannot try it without my dev computer), but I already use the Brutus method :)
# config/monolog.yaml
monolog:
foo: bar
Horatio Caine method: look in the source of monolog bundle, there is always a file describing the available options. In your case, I found solution in the `monolog.xml file :
# vendor/symfony/monolog-bundle/Resources/config/monolog.xml
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="monolog.logger" parent="monolog.logger_prototype" public="false">
<argument index="0">app</argument>
<call method="useMicrosecondTimestamps">
<argument>%monolog.use_microseconds%</argument>
</call>
</service>
...
I cannot try it on my phone, but it should solve your problem:
# config/monolog.yaml
monolog:
use_microseconds: false
edit: Since I found this use_microseconds config options, I just find on a old documentation an article about it:
https://symfony.com/doc/3.3/logging/disable_microsecond_precision.html
If you want to remove UTC, you could create your own Formatter. The handler uses a Formatter to format the record before logging it. All Monolog handlers use an instance of Monolog\Formatter\LineFormatter by default but you can replace it. Your new formatter must implement Monolog\Formatter\FormatterInterface. Here is the doc with a sample.
You can extends the LineFormatter and overload the constructor to use your format instead of the default one.
I'm attempting to run Spring Cloud Configuration Server, working through the examples in a book (Manning's Spring Microservices in Action), but updating to the latest versions: Java 17, spring-boot-starter-parent 2.6.1, with Spring Cloud 2021.0.0-RC1.
Each time I try to start the server, I get this error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you have set spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
I am not using the git profile. I have tried two different profiles: native (with config files on the classpath) and vault (with a Hashicorp Vault server running locally). My latest /src/resources/bootstrap.yml contains the following:
spring:
application:
name: config-server
profiles:
active: vault
cloud:
config:
server:
vault:
port: 8200
host: 127.0.0.1
kvVersion: 2
server:
port: 8071
My best guess is that the bootstrap.yml file isn't getting picked up at server startup, and perhaps the git profile is a default. How can I remedy this?
OK, it looks like the problem here is that newer versions of Spring Cloud Configuration Server don't look for the bootstrap.yml file by default. There are a few different ways to solve it. The easiest is just to move all the properties to an application.yml/application.properties instead.
Another alternative is (found at NEWBEDEV here) is to include a dependency that implements the "legacy" bootstrap behavior:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
add the following into application.properties file.
spring.application.name=techefx-spring-cloud-config-server
spring.cloud.config.server.git.uri=https://github.com/techefx/environment-variable-repo.git
server.port= ${port:8888}
Please go through the link below:
Spring Cloud Config File System Backend Issue (not reading properties from the file)
How to configure log4j to show only my
log.debug("test log");
messages in console without other system generated information?
It's very disturbing when in small app your console is messed with tons of useless ( at least for me) information like
DEBUG org.springframework.beans.CachedIntrospectionResults: Getting BeanInfo for class [org.thymeleaf.spring4.view.ThymeleafView]
my log4j.properties file:
log4j.rootLogger=DEBUG, stdout, file
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
You can use the LoggerMatchFilter and DenyAllFilter to restrict your logging appender to messages coming from your code only.
LoggerMatchFilter filter = new LoggerMatchFilter();
filter.setLoggerToMatch("Your.Root.Namespace");
filter.setAcceptOnMatch(true);
log4j.appender.stdout.addFilter(filter); // Match your messages only.
log4j.appender.stdout.addFilter(new DenyAllFilter()); // Don't match anything else.
Is your application using log4j or yet to configure??
log4j configure steps
If already log4j is in use, change the logger level to ERROR
Check whether your applications is using any xml configuration file for log4j or properties file so you can change in it.
logger level configuration steps.
I'm trying to setup a multi-NIC cluster with Cloudera5. Each node has an ethernet interface (eth1 - 172.17.2.x) plus an infiniband interface (ib0 - 192.168.69.x).
The problem is, the cluster communicates the infiniband addresses to the "outside world" when using HDFS.
I found out that the right parameter to get such a configuration working is "dfs.datanode.dns.interface" and that it has to be set to "eth1".
However, this parameter is not present in the Cloudera Manager interface. As it automatically overwrites the hdfs-site.xml file, I can't go to write it in the file.
I tried to use the Cloudera manager "Safety Valves" (Configuration > Service-Wide > Advanced > HDFS Service Advanced Configuration Snippet (Safety Valve) for hdfs-site.xml), and set it to
<property>
<name>dfs.datanode.dns.interface</name>
<value>eth1</value>
</property>
but the HDFS Canary fails.
Could anyone please
Confirm that it's the right parameter
give me some help on how to set
it in the Cloudera Manager interface ?
Thanks in advance.
You can add further configuration properties that is not present in the CM interface filling these field in the HDFS configuration page:
- HDFS Service Advanced Configuration Snippet (Safety Valve) for hdfs-site.xml"
- Cluster-wide Advanced Configuration Snippet (Safety Valve) for core-site.xml
- HDFS Service Advanced Configuration Snippet (Safety Valve) for hadoop-policy.xml
In yout case you have to insert this code:
<property>
<name>dfs.datanode.dns.interface</name>
<value>eth1</value>
</property>
in the HDFS Service Advanced Configuration Snippet
I have a problem in my application post moving to tomcat7. I am seeing the below issue when my app tries to connect to the "Oracle 11.2 DB".
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ORA-12541: TNS:no listener
)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:382)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:458)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:466)
The connection details in the server.xml and context.xml looks like below.
context.xml
ResourceLink global="jdbc/ctb" name="jdbc/ctb" type="oracle.jdbc.pool.OracleDataSource"/>
server.xml
<Resource name="jdbc/XXXX"
auth="Container"
scope="Shareable"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:oci8:#database"
username="username" password="pwd"
maxActive="30" maxIdle="3"
removeAbandoned="true" removeAbandonedTimeout="60"
testOnBorrow="true"
validationQuery="select 1 from dual"
logAbandoned="true" />
One observation i see is below:
The tomcat7 comes with a default jdbc driver in the "lib" folder called "tomcat-jdbc.jar". But in my app we are using spring-jdbc.jar from quite long.
Tried to remove each of them to make sure there wont be any conflict in the classes, but it never helped me.
tomcat6 workes fine with the same "context.xml" and "server.xml" and spring-jdbc.jar.
your help will be highly appreciated as this has become a blocker for our tomcat7 migration. Let me know if you need any further details.
==Benki
Oh Ghosh, pinned down the issue.
The setenv.sh script created never had the "ORACLE_HOME" path set for it which created in the above error. Also as i was using the init script was starting and stopping the tomcat, which loaded only the basic ENV variable required and set by setenv.sh script.
Everything is working fine now.