Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!

Nesamani Raman

Greenhorn
+ Follow
since Jun 18, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nesamani Raman

I have the following log4j2.xml configuration. I have a time as well as size based triggering policy. Since the size limit (10 MB) is breached first, the log file rolls over and while creating a new file, it appends wrong date to the filename. What I want is:
- Roll over when a file's size reaches 10 MB (total size of all files should not exceed 1500 times 10 MB)
- Roll over every 15 days

The file names should be abc.log, abc__2021-04-09__1.log, abc__2021-04-09__2.log. Basically it should have the current date appended to it.




Kindly let me know where am I wrong in my code. Thanks in advance.
3 weeks ago
So I came across https://github.com/Netflix/zuul/tree/master/zuul-core/src/main/java/com/netflix/netty/common/accesslog which has relevant code for access log for a zuul netty project. How do I use this in my log4j2 configuration to obtain access logs? Someone please help.
1 month ago
I want to print access logs for my zuul netty project which uses log4j2.xml. Following is my log4j2.xml configuration file:


I have as one of my JVM arguments. How do I print access logs for zuul netty java project? Came across a few links which print access logs for reactor netty but doesn't work for my project.
https://spring.getdocs.org/en-US/spring-cloud-docs/spring-cloud-gateway/reactor-netty-access-logs/reactor-netty-access-logs.html
https://github.com/reactor/reactor-netty/issues/301

Please help.
1 month ago
I have the following "log4j2.xml" configuration:



Dependencies in my build.gradle file are as follows:


Sample usage of logging in my Java project:


Following are the JVM arguments:


When I run the application, I get the following in my intellij console:


There seems to be an issue with SLF4J with log4j2. I want to use and only. Any other logging framework/imports will involve changing all files in my project. How do I get rid of these multiple bindings and warnings?

I am using Windows 10. IDE is Intellij.
1 month ago
I have the following log4j2 config in log4j2.xml which is not writing logs to file. I'm using windows 10. What am I doing wrong?



Following are the dependencies that I'm using:


Getting the following in my logs:


Sample code:


Am I missing something?
1 month ago
SRD notify method:



If you see the above code, it is not able to cast String (java.lang.String) to Value (com.orbitz.consul.model.kv.Value). I must necessarily use "Value", how can I convert "String" to "Value"? The code snippet you provided does not use "Value" at all.
8 months ago
That is exactly what I am unable to figure out. How to convert String to Value? I am unable to convert so by doing simple casting. Please guide me on this.
8 months ago
So I am testing a piece of code. Here's a code snippet of my test:



Following is the SRD notify method:



I am getting the following exception - How to resolve the same?
8 months ago
That works, it was so naive of me not to think of such an easy way. Thank you Stephan.
10 months ago
So I have a method (which compares JSON headers with HTTP headers and returns true if they match, else it returns false) against which I am trying to run a unit test written in Mockito. The method is as follows:



My unit test is as follows:



The test does not produce an output and instead is stuck in an infinite loop. Any reason why? Please help me.
10 months ago
Hi Carey,

Your point does make sense. We'll see the pros and cons before deciding whether to use a serial way or not. Anyway, I had a related question: we will be reading the JSON file by deserializing it using GSON to a Java POJO object and then do all this processing. I wanted to know - do we need the "id" field at all? It might not be required if the order in which elements appear in the JSON is the order in which they will be deserialized using GSON. Does GSON preserve the ordering of elements while deserializing? Let's say I have the following structure, can I still implement my business logic of selecting the first occuring element satisfying a particular condition but without having the "id" field? Please shed some light. A similar problem is talked about here - https://stackoverflow.com/questions/21009110/maintaining-same-order-as-jsonarray-while-de-serializing-using-gson . Just want to confirm the exact behavior.


"ruleItems":
[
  {
      "path": "true",
      "action": "a1"
  },

  {
      "path": "false",
      "action": "a2"
  },

  {
      "path": "false",
      "action": "a3"
  },

  {
      "path": "true",
      "action": "a4"
  }
]
1 year ago
Hi Tim,

Yes you are right, multi-threaded/parallel way is for performance enhancement. We thought it would be better to give each element to a thread and let it do the processing and then we'll merge and find the appropriate element. Won't it be faster than iterating over each element one by one in a serial way? I am a noob, so kindly bear with me.
1 year ago
This JSON configuration is a subset of the whole thing. What if there are a lot of elements within "ruleItems" and each element has multiple fields on which processing has to be done (equivalent to "path" = true) after which we have to select the lowest "id". Also, we will be deserializing the JSON file to a Java POJO object and then do the processing. We are looking for a Java Stream API to do parallel processing and then merge the results.
1 year ago