Is there any movie of the X-Men universe needed to fully understand the Logan movie? Or is it a independent (or prequel) story?
Well, there is no need to watch any previous movies in X-Men film series in order to watch Logan.
However, if you have some character knowledge about Professor X and Wolverine, it'll be nice.
This movie is set in 2029, after the events of Days of Future Past, but there is no link to it or any movie before this.
Logan is more of individual character story of Wolverine but it used established characters like Charles Xavier/Professor X in major role and this Charles was part of X-Men, X2, X-Men: The Last Stand and X-Men: Days of Future Past.
So I will recommend watching original trilogy to understand about Logan and Charles's character.
Deadpool, X-Men: First Class, X-Men: Days of Future Past are not necessary and X-Men Origins: Wolverine is not canon at all after the time travel stuff happen in Days of Future Past. You can watch The Wolverine but it has no much impact on the film except having the same main lead character.
It did have connections to X-Men: Apocalypse
Caliban had small cameo in X-Men: Apocalypse played by different actor. And end credit scene shows how (Spoiler Ahead):
They got Logan's blood
and also it have connection to one of the Logan's villain
During the Wolverine outbreak in the film he killed Zander Rice's father.
But for understanding Apocalypse, you need to watch X-Men: First Class and X-Men: Days of Future Past. Or just read the spoiler only and watch original trilogy to understand the character of Wolverine and Professor X.